Skip to content

Commit 9fb6b8a

Browse files
Merge pull request #51 from CobraSphere/updated-for-php8
Updated for PHP 8. Tested most with Unit Tests.
2 parents 71df4c8 + 446adb1 commit 9fb6b8a

9 files changed

+47
-14
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ vendor
33
nbproject/*
44
.idea
55
composer.lock
6-
build
6+
build
7+
.phpunit.result.cache

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"keywords": ["mailerlite", "sdk", "email", "marketing"],
77
"type": "library",
88
"require": {
9-
"php" : "^7.1",
9+
"php" : "^7.1 || ^8.0",
1010
"php-http/client-common": "^2.0",
1111
"php-http/discovery": "^1.7",
1212
"nyholm/psr7": "^1.0",

phpunit.xml

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
<phpunit bootstrap="tests/bootstrap.php"
2-
colors="true"
3-
stopOnFailure="false">
1+
<?xml version="1.0"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" colors="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage/>
44
<testsuites>
55
<testsuite name="client">
66
<directory>tests</directory>
77
</testsuite>
88
</testsuites>
99
<logging>
10-
<log type="tap" target="build/report.tap"/>
11-
<log type="junit" target="build/report.junit.xml"/>
10+
<junit outputFile="build/report.junit.xml"/>
1211
<!-- <log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
1312
<log type="coverage-text" target="build/coverage.txt"/>
1413
<log type="coverage-clover" target="build/logs/clover.xml"/> -->
1514
</logging>
16-
</phpunit>
15+
</phpunit>

phpunit.xml.bak

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<phpunit bootstrap="tests/bootstrap.php"
2+
colors="true"
3+
stopOnFailure="false">
4+
<testsuites>
5+
<testsuite name="client">
6+
<directory>tests</directory>
7+
</testsuite>
8+
</testsuites>
9+
<logging>
10+
<log type="tap" target="build/report.tap"/>
11+
<log type="junit" target="build/report.junit.xml"/>
12+
<!-- <log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
13+
<log type="coverage-text" target="build/coverage.txt"/>
14+
<log type="coverage-clover" target="build/logs/clover.xml"/> -->
15+
</logging>
16+
</phpunit>

tests/BatchTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ public function send_batch()
4646
->setMethod(BatchRequest::METHOD_POST)
4747
->setPath('/api/v2/subscribers')
4848
->setBody([
49-
'email' => '[email protected]',
49+
'email' => BATCH_TEST_EMAIL1,
5050
]);
5151

5252
$batchTwo = (new BatchRequest())
5353
->setMethod(BatchRequest::METHOD_POST)
5454
->setPath('/api/v2/subscribers')
5555
->setBody([
56-
'email' => '[email protected]',
56+
'email' => BATCH_TEST_EMAIL2,
5757
]);
5858

5959
$requests[] = $batchOne;

tests/CampaignsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function create_campaign()
2424
$campaignData = [
2525
'subject' => 'Regular Campaign Subject',
2626
'type' => 'regular',
27-
'groups' => [2984475, 3237221] // TODO: improve this with creating new groups
27+
'groups' => [CAMPAIGNS_TEST_GROUP1, CAMPAIGNS_TEST_GROUP2] // TODO: improve this with creating new groups
2828
];
2929

3030
$campaign = $this->campaignsApi->create($campaignData);

tests/SegmentsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public function get_segments()
2525
{
2626
$segments = $this->segmentsApi->get();
2727

28-
$this->assertContains('Demo segment', (array) $segments->first()->data[0]);
28+
$this->assertContains(SEGMENTS_TEST_NAME1, (array) $segments->first()->data[0]);
2929
}
3030
}

tests/SubscribersTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function update_subscriber()
6767
/** @test **/
6868
public function search_for_a_subscriber()
6969
{
70-
$subscribers = $this->subscribersApi->search('[email protected]');
70+
$subscribers = $this->subscribersApi->search(SUBSCRIBERS_TEST_EMAIL1);
7171

7272
$this->assertTrue(count($subscribers) > 0);
7373
}

tests/bootstrap.php

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
<?php
2+
23
require_once __DIR__ . '/../vendor/autoload.php';
34

4-
define('API_KEY', 'fc7b8c5b32067bcd47cafb5f475d2fe9'); // demo account
5+
// demo account
6+
define('API_KEY', 'fc7b8c5b32067bcd47cafb5f475d2fe9');
7+
define('BATCH_TEST_EMAIL1', '[email protected]');
8+
define('BATCH_TEST_EMAIL2', '[email protected]');
9+
define('SUBSCRIBERS_TEST_EMAIL1', '[email protected]');
10+
define('CAMPAIGNS_TEST_GROUP1', 2984475);
11+
define('CAMPAIGNS_TEST_GROUP2', 3237221);
12+
define('SEGMENTS_TEST_NAME1', 'Demo segment');
13+
14+
// other account (other devs) (adapt below as required)
15+
// define('API_KEY', 'XXX');
16+
// define('BATCH_TEST_EMAIL1', '[email protected]');
17+
// define('BATCH_TEST_EMAIL2', '[email protected]');
18+
// define('SUBSCRIBERS_TEST_EMAIL1', '[email protected]');
19+
// define('CAMPAIGNS_TEST_GROUP1', 000000000);
20+
// define('CAMPAIGNS_TEST_GROUP2', 000000000);
21+
// define('SEGMENTS_TEST_NAME1', 'SDK Test');

0 commit comments

Comments
 (0)