1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
||
5 | * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
||
6 | */ |
||
7 | |||
8 | namespace SprykerTest\Glue\GlueApplication\Rest\Request; |
||
9 | |||
10 | use Codeception\Test\Unit; |
||
11 | use Generated\Shared\Transfer\RestErrorMessageTransfer; |
||
12 | use Spryker\Glue\GlueApplication\Rest\User\RestUserValidator; |
||
13 | use Spryker\Glue\GlueApplication\Rest\User\RestUserValidatorInterface; |
||
14 | use Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\RestUserValidatorPluginInterface; |
||
15 | use SprykerTest\Glue\GlueApplication\Stub\RestRequest; |
||
16 | |||
17 | /** |
||
18 | * @deprecated Will be removed without replacement. |
||
19 | * |
||
20 | * Auto-generated group annotations |
||
21 | * |
||
22 | * @group SprykerTest |
||
23 | * @group Glue |
||
24 | * @group GlueApplication |
||
25 | * @group Rest |
||
26 | * @group Request |
||
27 | * @group RestUserValidatorTest |
||
28 | * |
||
29 | * Add your own group annotations below this line |
||
30 | */ |
||
31 | class RestUserValidatorTest extends Unit |
||
32 | { |
||
33 | /** |
||
34 | * @return void |
||
35 | */ |
||
36 | public function testValidateWhenPluginSucceedsShouldReturnNull(): void |
||
37 | { |
||
38 | // Arrange |
||
39 | $restUserValidatorPluginMock = $this->createRestUserValidatorPluginMock(); |
||
40 | $restUserValidatorPluginMock |
||
41 | ->method('validate') |
||
0 ignored issues
–
show
|
|||
42 | ->willReturn(null); |
||
43 | $restUserValidator = $this->createRestUserValidator([$restUserValidatorPluginMock]); |
||
44 | $restRequest = (new RestRequest())->createRestRequest(); |
||
45 | |||
46 | // Act |
||
47 | $restErrorCollectionTransfer = $restUserValidator->validate($restRequest); |
||
48 | |||
49 | // Assert |
||
50 | $this->assertNull($restErrorCollectionTransfer); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @return void |
||
55 | */ |
||
56 | public function testValidateWhenPluginFailsShouldReturnError(): void |
||
57 | { |
||
58 | // Arrange |
||
59 | $restUserValidatorPluginMock = $this->createRestUserValidatorPluginMock(); |
||
60 | $restUserValidatorPluginMock |
||
61 | ->method('validate') |
||
62 | ->willReturn(new RestErrorMessageTransfer()); |
||
63 | $restUserValidator = $this->createRestUserValidator([$restUserValidatorPluginMock]); |
||
64 | $restRequest = (new RestRequest())->createRestRequest(); |
||
65 | |||
66 | // Act |
||
67 | $restErrorCollectionTransfer = $restUserValidator->validate($restRequest); |
||
68 | |||
69 | // Assert |
||
70 | $this->assertNotEmpty($restErrorCollectionTransfer); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @return \Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\RestUserValidatorPluginInterface|\PHPUnit\Framework\MockObject\MockObject |
||
75 | */ |
||
76 | protected function createRestUserValidatorPluginMock(): RestUserValidatorPluginInterface |
||
77 | { |
||
78 | return $this->getMockBuilder(RestUserValidatorPluginInterface::class) |
||
79 | ->onlyMethods(['validate']) |
||
80 | ->getMock(); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @param array<\Spryker\Glue\GlueApplicationExtension\Dependency\Plugin\RestUserValidatorPluginInterface> $restUserValidatorPlugins |
||
85 | * |
||
86 | * @return \Spryker\Glue\GlueApplication\Rest\User\RestUserValidatorInterface |
||
87 | */ |
||
88 | protected function createRestUserValidator(array $restUserValidatorPlugins = []): RestUserValidatorInterface |
||
89 | { |
||
90 | return new RestUserValidator($restUserValidatorPlugins); |
||
91 | } |
||
92 | } |
||
93 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.