1- <?php
1+ <?php /** @noinspection PhpUnhandledExceptionInspection */
22
33/**
44 * Telegram Bot API.
@@ -31,19 +31,13 @@ final class InteractionsProviderTest extends TestCase
3131 */
3232 private $ credentials ;
3333
34- /**
35- * {@inheritdoc}
36- */
3734 protected function setUp (): void
3835 {
3936 parent ::setUp ();
4037
4138 $ this ->credentials = new TelegramCredentials ('25896951:AAGB5PnXUTW-SuI4CIe742FKcTvPEwP82_o ' );
4239 }
4340
44- /**
45- * {@inheritdoc}
46- */
4741 protected function tearDown (): void
4842 {
4943 parent ::tearDown ();
@@ -55,101 +49,97 @@ protected function tearDown(): void
5549
5650 /**
5751 * @test
58- *
59- * @return void
6052 */
6153 public function unknownMethod (): void
6254 {
6355 Loop::run (
64- function (): \Generator
56+ function (): \Generator
6557 {
6658 /** @var \ServiceBus\TelegramBot\Interaction\Result\Fail $result */
6759 $ result = yield (new InteractionsProvider (TestHttpClient::create ('{} ' , 404 )))->call (
6860 new TestMethod (),
6961 $ this ->credentials
7062 );
7163
72- static ::assertInstanceOf (Fail::class, $ result );
73- static ::assertSame ('Method TestMethod not exists ' , $ result ->errorMessage );
64+ self ::assertInstanceOf (Fail::class, $ result );
65+ self ::assertSame ('Method TestMethod not exists ' , $ result ->errorMessage );
7466 }
7567 );
7668 }
7769
7870 /**
7971 * @test
80- *
81- * @return void
8272 */
8373 public function validationFailed (): void
8474 {
8575 Loop::run (
86- function (): \Generator
76+ function (): \Generator
8777 {
8878 /** @var \ServiceBus\TelegramBot\Interaction\Result\Fail $result */
8979 $ result = yield (new InteractionsProvider (TestHttpClient::create ('{} ' , 404 )))->call (
9080 new TestMethod ('' ),
9181 $ this ->credentials
9282 );
9383
94- static ::assertInstanceOf (Fail::class, $ result );
95- static ::assertSame ('Validation failed ' , $ result ->errorMessage );
84+ self ::assertInstanceOf (Fail::class, $ result );
85+ self ::assertSame ('Validation failed ' , $ result ->errorMessage );
86+
87+ Loop::stop ();
9688 }
9789 );
9890 }
9991
10092 /**
10193 * @test
102- *
103- * @return void
10494 */
10595 public function internalError (): void
10696 {
10797 Loop::run (
108- function (): \Generator
98+ function (): \Generator
10999 {
110100 /** @var \ServiceBus\TelegramBot\Interaction\Result\Fail $result */
111101 $ result = yield (new InteractionsProvider (TestHttpClient::create ('{} ' , 500 )))->call (
112102 new TestMethod (),
113103 $ this ->credentials
114104 );
115105
116- static ::assertInstanceOf (Fail::class, $ result );
117- static ::assertSame ('Incorrect server response code: 500 ' , $ result ->errorMessage );
106+ self ::assertInstanceOf (Fail::class, $ result );
107+ self ::assertSame ('Incorrect server response code: 500 ' , $ result ->errorMessage );
108+
109+ Loop::stop ();
118110 }
119111 );
120112 }
121113
122114 /**
123115 * @test
124- *
125- * @return void
126116 */
127117 public function incorrectResponsePayload (): void
128118 {
129119 Loop::run (
130- function (): \Generator
120+ function (): \Generator
131121 {
132122 /** @var \ServiceBus\TelegramBot\Interaction\Result\Fail $result */
133123 $ result = yield (new InteractionsProvider (TestHttpClient::create ('{} ' , 200 )))->call (
134124 new TestMethod (),
135125 $ this ->credentials
136126 );
137127
138- static ::assertInstanceOf (Fail::class, $ result );
139- static ::assertSame ('Incorrect response payload ' , $ result ->errorMessage );
128+ self ::assertInstanceOf (Fail::class, $ result );
129+ self ::assertSame ('Incorrect response payload ' , $ result ->errorMessage );
130+
131+ Loop::stop ();
140132 }
141133 );
142134 }
143135
144136 /**
145137 * @test
146- *
147- * @return void
148138 */
149139 public function successRequest (): void
150140 {
151141 Loop::run (
152- function (): \Generator
142+ function (): \Generator
153143 {
154144 $ expectedResponse = '{"ok":true,"result":{"id":1,"is_bot":true,"first_name":"First","last_name":"","username":"User"}} ' ;
155145
@@ -159,55 +149,57 @@ function (): \Generator
159149 $ this ->credentials
160150 );
161151
162- static ::assertInstanceOf (Success::class, $ result );
152+ self ::assertInstanceOf (Success::class, $ result );
163153
164154 /** @var User $type */
165155 $ type = $ result ->type ;
166156
167- static ::assertSame ('1 ' , $ type ->id ->toString ());
157+ self ::assertSame ('1 ' , $ type ->id ->toString ());
158+
159+ Loop::stop ();
168160 }
169161 );
170162 }
171163
172164 /**
173165 * @test
174- *
175- * @return void
176166 */
177167 public function failedDownload (): void
178168 {
179169 Loop::run (
180- function (): \Generator
170+ function (): \Generator
181171 {
182172 /** @var \ServiceBus\TelegramBot\Interaction\Result\Fail $result */
183173 $ result = yield (new InteractionsProvider (TestHttpClient::failed ('fail message ' )))->call (
184174 DownloadFile::create ('' , '' , '' ),
185175 $ this ->credentials
186176 );
187177
188- static ::assertInstanceOf (Fail::class, $ result );
189- static ::assertSame ('fail message ' , $ result ->errorMessage );
178+ self ::assertInstanceOf (Fail::class, $ result );
179+ self ::assertSame ('fail message ' , $ result ->errorMessage );
180+
181+ Loop::stop ();
190182 }
191183 );
192184 }
193185
194186 /**
195187 * @test
196- *
197- * @return void
198188 */
199189 public function successDownload (): void
200190 {
201191 Loop::run (
202- function (): \Generator
192+ function (): \Generator
203193 {
204194 /** @var \ServiceBus\TelegramBot\Interaction\Result\Success $result */
205195 $ result = yield (new InteractionsProvider (TestHttpClient::create ('' , 200 )))->call (
206196 DownloadFile::create ('' , '' , '' ),
207197 $ this ->credentials
208198 );
209199
210- static ::assertInstanceOf (Success::class, $ result );
200+ self ::assertInstanceOf (Success::class, $ result );
201+
202+ Loop::stop ();
211203 }
212204 );
213205 }
0 commit comments