-
-
Notifications
You must be signed in to change notification settings - Fork 11
Tests addition #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Tests addition #46
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Yiisoft\Yii\Testing\Tests; | ||
|
|
||
| use PHPUnit\Framework\TestCase; | ||
| use Yiisoft\Yii\Testing\MockServiceProvider; | ||
|
|
||
| class MockServiceProviderTest extends TestCase | ||
| { | ||
| public function testGetDefinitionsWillReturnDefinitionsSetInArray(): void | ||
| { | ||
| $mockServiceProvider = new MockServiceProvider(); | ||
| $mockServiceProvider->setDefinition('example-id-001', ['class' => 'Example1\Class1\Position1']); | ||
| $mockServiceProvider->setDefinition('example-id-002', 'Example1\Class2\Position2'); | ||
| $mockServiceProvider->setDefinition('example-id-003', 'Example3\Class3\Position3'); | ||
|
|
||
| $this->assertEquals([ | ||
| 'example-id-001' => ['class' => 'Example1\Class1\Position1'], | ||
| 'example-id-002' => 'Example1\Class2\Position2', | ||
| 'example-id-003' => 'Example3\Class3\Position3', | ||
| ], $mockServiceProvider->getDefinitions()); | ||
| } | ||
|
|
||
| public function testGetExtensionsWillReturnEmptyArray(): void | ||
| { | ||
| $this->assertEmpty((new MockServiceProvider())->getExtensions()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Yiisoft\Yii\Testing\Tests; | ||
|
|
||
| use Nyholm\Psr7\Response; | ||
| use PHPUnit\Framework\TestCase; | ||
| use RuntimeException; | ||
| use Yiisoft\Yii\Testing\ResponseAccessor; | ||
| use Yiisoft\Yii\Testing\ResponseGrabber; | ||
|
|
||
| class ResponseGrabberTest extends TestCase | ||
| { | ||
| public function testGetResponseWillReturnResponseAccessorSetResponse(): void | ||
| { | ||
| $response = new Response(200, body: '{"key": "value"}', reason: 'Ok with body', version: '1.1'); | ||
|
|
||
| $responseGrabber = new ResponseGrabber(); | ||
| $responseGrabber->setResponse($response); | ||
|
|
||
| $this->assertEquals(new ResponseAccessor($response), $responseGrabber->getResponse()); | ||
| } | ||
|
|
||
| public function testGetResponseWillThrowExceptionIfSetResponseIsCalledWithNullParameter(): void | ||
| { | ||
| $this->expectException(RuntimeException::class); | ||
| $this->expectExceptionMessage('Response is null'); | ||
|
|
||
| $responseGrabber = new ResponseGrabber(); | ||
| $responseGrabber->setResponse(null); | ||
| $responseGrabber->getResponse(); | ||
| } | ||
|
|
||
| public function testGetResponseWillThrowExceptionIfResponseIsNotSet(): void | ||
| { | ||
| $this->expectException(RuntimeException::class); | ||
| $this->expectExceptionMessage('Response is null'); | ||
|
|
||
| (new ResponseGrabber())->getResponse(); | ||
| } | ||
|
Comment on lines
+15
to
+41
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests do not correspond to real usage. Would you please make it closer to real usage?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you provide a link where I can find real usages? I'll check it and modify both tests |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests do not correspond to real usage of the provider. Would you please make it closer to real usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide a link where I can find real usages? I'll check it and modify both tests