first commit

This commit is contained in:
2024-12-17 13:43:22 +01:00
commit 8e6cd8b410
21292 changed files with 3514826 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
<?php
namespace DrewM\MailChimp\Tests;
use DrewM\MailChimp\MailChimp;
use PHPUnit\Framework\TestCase;
class BatchTest extends TestCase
{
/**
* @throws \Exception
*/
public function testNewBatch()
{
$MC_API_KEY = getenv('MC_API_KEY');
if (!$MC_API_KEY) {
$this->markTestSkipped('No API key in ENV');
}
$MailChimp = new MailChimp($MC_API_KEY);
$Batch = $MailChimp->new_batch('1');
$this->assertInstanceOf('\DrewM\MailChimp\Batch', $Batch);
$this->assertSame(array(), $Batch->get_operations());
}
}

View File

@@ -0,0 +1,21 @@
<?php
use DrewM\MailChimp\MailChimp;
use PHPUnit\Framework\TestCase;
class ListsTest extends TestCase
{
public function testGetLists()
{
$MC_API_KEY = getenv('MC_API_KEY');
if (!$MC_API_KEY) {
$this->markTestSkipped('No API key in ENV');
}
$MailChimp = new MailChimp($MC_API_KEY);
$lists = $MailChimp->get('lists');
$this->assertArrayHasKey('lists', $lists);
}
}

View File

@@ -0,0 +1,115 @@
<?php
namespace DrewM\MailChimp\Tests;
use DrewM\MailChimp\MailChimp;
use PHPUnit\Framework\TestCase;
class MailChimpTest extends TestCase
{
/**
* @throws \Exception
*/
public function testInvalidAPIKey()
{
$this->expectException('\Exception');
new MailChimp('abc');
}
public function testTestEnvironment()
{
$MC_API_KEY = getenv('MC_API_KEY');
$this->assertNotEmpty($MC_API_KEY, 'No environment variables! Copy .env.example -> .env and fill out your MailChimp account details.');
}
/**
* @throws \Exception
*/
public function testInstantiation()
{
$MC_API_KEY = getenv('MC_API_KEY');
if (!$MC_API_KEY) {
$this->markTestSkipped('No API key in ENV');
}
$MailChimp = new MailChimp($MC_API_KEY, 'https://api.mailchimp.com/3.0');
$this->assertInstanceOf('\DrewM\MailChimp\MailChimp', $MailChimp);
$this->assertSame('https://api.mailchimp.com/3.0', $MailChimp->getApiEndpoint());
$this->assertFalse($MailChimp->success());
$this->assertFalse($MailChimp->getLastError());
$this->assertSame(array('headers' => null, 'body' => null), $MailChimp->getLastResponse());
$this->assertSame(array(), $MailChimp->getLastRequest());
}
/**
* @throws \Exception
*/
public function testSubscriberHash()
{
$MC_API_KEY = getenv('MC_API_KEY');
if (!$MC_API_KEY) {
$this->markTestSkipped('No API key in ENV');
}
$MailChimp = new MailChimp($MC_API_KEY);
$email = 'Foo@Example.Com';
$expected = md5(strtolower($email));
$result = $MailChimp->subscriberHash($email);
$this->assertEquals($expected, $result);
}
public function testResponseState()
{
$MC_API_KEY = getenv('MC_API_KEY');
if (!$MC_API_KEY) {
$this->markTestSkipped('No API key in ENV');
}
$MailChimp = new MailChimp($MC_API_KEY);
$MailChimp->get('lists');
$this->assertTrue($MailChimp->success());
}
/* This test requires that your test list have:
* a) a list
* b) enough entries that the curl request will timeout after 1 second.
* How many this is may depend on your network connection to the Mailchimp servers.
*/
/*
public function testRequestTimeout()
{
$this->markTestSkipped('CI server too fast to realistically test.');
$MC_API_KEY = getenv('MC_API_KEY');
if (!$MC_API_KEY) {
$this->markTestSkipped('No API key in ENV');
}
$MailChimp = new MailChimp($MC_API_KEY);
$result = $MailChimp->get('lists');
$list_id = $result['lists'][0]['id'];
$args = array( 'count' => 1000 );
$timeout = 1;
$result = $MailChimp->get("lists/$list_id/members", $args, $timeout );
$this->assertFalse( $result );
$error = $MailChimp->getLastError();
$this->assertRegExp( '/Request timed out after 1.\d+ seconds/', $error );
}
*/
}

View File

@@ -0,0 +1,16 @@
<?php
\error_reporting(E_ALL);
include_once \dirname(__DIR__) . '/vendor/autoload.php';
if (!\class_exists('Dotenv\Dotenv')) {
throw new \RuntimeException('You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
$env_file_path = __DIR__ . '/../';
if (file_exists($env_file_path . '.env')) {
$dotenv = new Dotenv\Dotenv($env_file_path);
$dotenv->load();
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;