CampaignMonitorTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 32
dl 0
loc 47
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testItCanBeUsedByCMClasses() 0 45 1
1
<?php
2
3
namespace Amesplash\CampaignMonitorLog\Functional;
4
5
use CS_REST_Campaigns;
6
use Psr\Log\LoggerInterface;
7
use PHPUnit\Framework\TestCase;
8
use Eloquent\Phony\Phpunit\Phony;
9
use Amesplash\CampaignMonitorLog\LogDecorator;
10
11
class CampaignMonitorTest extends TestCase
12
{
13
    public function testItCanBeUsedByCMClasses()
14
    {
15
        $psrLogHandle = Phony::partialMock(LoggerInterface::class, null);
16
        $psrLogMock = $psrLogHandle->get();
17
        $psrLogDecorator = new LogDecorator($psrLogMock);
18
19
        $subscriber = new CS_REST_Campaigns(
20
            'campaign_id',
21
            ['api_key' => 'api-key'],
22
            'https',
23
            CS_REST_LOG_VERBOSE,
24
            'api.createsend.com',
25
            $psrLogDecorator
26
        );
27
28
        $psrLogHandle->log->calledWith(
29
            'debug',
30
            'Creating wrapper for https://api.createsend.com/api/v3.2/',
31
            ['module' => 'CS_REST_Campaigns']
32
        );
33
34
        $psrLogHandle->log->calledWith(
35
            'warning',
36
            'Using cURL for transport',
37
            ['module' => 'CS_REST_Campaigns']
38
        );
39
40
        $psrLogHandle->log->calledWith(
41
            'warning',
42
            'Using native json serialising',
43
            ['module' => 'CS_REST_Campaigns']
44
        );
45
46
        $psrLogHandle->log->calledWith(
47
            'debug',
48
            'Getting serialiser',
49
            ['module' => 'CS_REST_SERIALISATION_get_available']
50
        );
51
52
        $subscriber->create('client_id', ['Subject' => 'Test']);
53
54
        $psrLogHandle->log->calledWith(
55
            'debug',
56
            "Call result: <pre>array (\n  'code' => 401,\n  'response' => '{\"Code\":50,\"Message\":\"Must supply a valid HTTP Basic Authorization header\"}',\n)</pre>",
57
            ['module' => 'CS_REST_Campaigns']
58
        );
59
    }
60
}
61