@@ 70-94 (lines=25) @@ | ||
67 | } |
|
68 | ||
69 | /** @test */ |
|
70 | public function it_throws_an_exception_if_subscribing_someone_fails() |
|
71 | { |
|
72 | $email = '[email protected]'; |
|
73 | ||
74 | $url = 'lists/123/members'; |
|
75 | ||
76 | $this->mailChimpApi->shouldReceive('success')->andReturn(false); |
|
77 | $this->mailChimpApi->shouldReceive('post')->withArgs([ |
|
78 | $url, |
|
79 | [ |
|
80 | 'email_address' => $email, |
|
81 | 'status' => 'subscribed', |
|
82 | 'email_type' => 'html', |
|
83 | ], |
|
84 | ])->andReturn('failure'); |
|
85 | ||
86 | try { |
|
87 | $this->newsletter->subscribe($email); |
|
88 | } catch (FailedResponse $e) { |
|
89 | $this->assertEquals('failure', $e->response); |
|
90 | return; |
|
91 | } |
|
92 | ||
93 | $this->fail('Expected FailedResponse exception to be thrown'); |
|
94 | } |
|
95 | ||
96 | /** @test */ |
|
97 | public function it_can_subscribe_someone_as_pending() |
|
@@ 117-141 (lines=25) @@ | ||
114 | } |
|
115 | ||
116 | /** @test */ |
|
117 | public function it_throws_an_exception_if_subscribing_someone_as_pending_fails() |
|
118 | { |
|
119 | $email = '[email protected]'; |
|
120 | ||
121 | $url = 'lists/123/members'; |
|
122 | ||
123 | $this->mailChimpApi->shouldReceive('success')->andReturn(false); |
|
124 | $this->mailChimpApi->shouldReceive('post')->withArgs([ |
|
125 | $url, |
|
126 | [ |
|
127 | 'email_address' => $email, |
|
128 | 'status' => 'pending', |
|
129 | 'email_type' => 'html', |
|
130 | ], |
|
131 | ])->andReturn('failure'); |
|
132 | ||
133 | try { |
|
134 | $this->newsletter->subscribePending($email); |
|
135 | } catch (FailedResponse $e) { |
|
136 | $this->assertEquals('failure', $e->response); |
|
137 | return; |
|
138 | } |
|
139 | ||
140 | $this->fail('Expected FailedResponse exception to be thrown'); |
|
141 | } |
|
142 | ||
143 | /** @test */ |
|
144 | public function it_can_subscribe_or_update_someone() |