1 | <?php |
||||||
2 | |||||||
3 | declare(strict_types=1); |
||||||
4 | |||||||
5 | namespace Tests\Service; |
||||||
6 | |||||||
7 | use PHPUnit\Framework\TestCase; |
||||||
8 | use Sendy\SendyBundle\SendyException; |
||||||
9 | use Sendy\SendyBundle\Service\SendyManager; |
||||||
10 | use Sendy\SendyBundle\Service\SendyManagerInterface; |
||||||
11 | use Tests\Mocks\SendyPHP; |
||||||
12 | |||||||
13 | final class SendyManagerTest extends TestCase |
||||||
14 | { |
||||||
15 | /** @var SendyManager */ |
||||||
16 | private $manager = null; |
||||||
17 | |||||||
18 | protected function setUp(): void |
||||||
19 | { |
||||||
20 | parent::setUp(); |
||||||
21 | |||||||
22 | // create mock for SendyPHP library |
||||||
23 | $sendy = new SendyPHP([ |
||||||
24 | 'api_key' => 'example_key', |
||||||
25 | 'installation_url' => 'example.host', |
||||||
26 | 'list_id' => 'example_list', |
||||||
27 | ]); |
||||||
28 | |||||||
29 | // create SendyManager object |
||||||
30 | $this->manager = new SendyManager($sendy); |
||||||
31 | } |
||||||
32 | |||||||
33 | protected function tearDown(): void |
||||||
34 | { |
||||||
35 | unset($this->manager); |
||||||
36 | } |
||||||
37 | |||||||
38 | public function testImplementedInterface(): void |
||||||
39 | { |
||||||
40 | self::assertInstanceOf(SendyManagerInterface::class, $this->manager); |
||||||
41 | } |
||||||
42 | |||||||
43 | public function testGetSubscriberCount(): void |
||||||
44 | { |
||||||
45 | self::assertEquals(2, $this->manager->getSubscriberCount()); |
||||||
46 | } |
||||||
47 | |||||||
48 | public function testGetSubscriberCountWithWrongList(): void |
||||||
49 | { |
||||||
50 | self::expectException(SendyException::class); |
||||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||||||
51 | $this->manager->getSubscriberCount('wrong_list'); |
||||||
52 | } |
||||||
53 | |||||||
54 | public function testGetSubscriberStatus(): void |
||||||
55 | { |
||||||
56 | self::assertEquals('Subscribed', $this->manager->getSubscriberStatus('[email protected]')); |
||||||
57 | } |
||||||
58 | |||||||
59 | public function testGetSubscriberStatusWithWrongEmail(): void |
||||||
60 | { |
||||||
61 | self::expectException(SendyException::class); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCase::expectException() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
62 | $this->manager->getSubscriberStatus('[email protected]'); |
||||||
63 | } |
||||||
64 | |||||||
65 | public function testGetSubscriberStatusWithWrongList(): void |
||||||
66 | { |
||||||
67 | self::expectException(SendyException::class); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCase::expectException() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
68 | $this->manager->getSubscriberStatus('[email protected]', 'wrong_list'); |
||||||
69 | } |
||||||
70 | |||||||
71 | /** |
||||||
72 | * @doesNotPerformAssertions |
||||||
73 | */ |
||||||
74 | public function testSubscribeWithNewEmail(): void |
||||||
75 | { |
||||||
76 | $this->manager->subscribe('Fred Combs', '[email protected]'); |
||||||
77 | } |
||||||
78 | |||||||
79 | /** |
||||||
80 | * @doesNotPerformAssertions |
||||||
81 | */ |
||||||
82 | public function testSubscribeWithExistentEmail(): void |
||||||
83 | { |
||||||
84 | $this->manager->subscribe('John Doe', '[email protected]'); |
||||||
85 | } |
||||||
86 | |||||||
87 | public function testSubscribeWithWrongList(): void |
||||||
88 | { |
||||||
89 | self::expectException(SendyException::class); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCase::expectException() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
90 | $this->manager->subscribe('Fred Combs', '[email protected]', 'wrong_list'); |
||||||
91 | } |
||||||
92 | |||||||
93 | /** |
||||||
94 | * @doesNotPerformAssertions |
||||||
95 | */ |
||||||
96 | public function testUnsubscribe(): void |
||||||
97 | { |
||||||
98 | $this->manager->unsubscribe('[email protected]'); |
||||||
99 | } |
||||||
100 | |||||||
101 | public function testUnsubscribeWithWrongEmail(): void |
||||||
102 | { |
||||||
103 | self::expectException(SendyException::class); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCase::expectException() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
104 | $this->manager->unsubscribe('[email protected]'); |
||||||
105 | } |
||||||
106 | |||||||
107 | public function testUnsubscribeWithWrongList(): void |
||||||
108 | { |
||||||
109 | self::expectException(SendyException::class); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCase::expectException() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
110 | $this->manager->unsubscribe('[email protected]', 'wrong_list'); |
||||||
111 | } |
||||||
112 | } |
||||||
113 |