1 | <?php |
||||||
2 | |||||||
3 | namespace Azine\EmailUpdateConfirmationBundle\Tests; |
||||||
4 | |||||||
5 | use Azine\EmailUpdateConfirmationBundle\Services\EmailUpdateConfirmation; |
||||||
6 | use FOS\UserBundle\Mailer\MailerInterface; |
||||||
7 | use FOS\UserBundle\Model\User; |
||||||
8 | use FOS\UserBundle\Util\TokenGenerator; |
||||||
9 | use Symfony\Component\EventDispatcher\EventDispatcher; |
||||||
10 | use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; |
||||||
0 ignored issues
–
show
|
|||||||
11 | use Symfony\Component\Routing\RouterInterface; |
||||||
12 | use Symfony\Component\Validator\ConstraintViolationList; |
||||||
13 | use Symfony\Component\Validator\Validator\ValidatorInterface; |
||||||
14 | |||||||
15 | class EmailUpdateConfirmationTest extends \PHPUnit\Framework\TestCase |
||||||
16 | { |
||||||
17 | /** @var ExpressionFunctionProviderInterface */ |
||||||
18 | private $provider; |
||||||
19 | /** @var RouterInterface */ |
||||||
20 | private $router; |
||||||
21 | /** @var TokenGenerator */ |
||||||
22 | private $tokenGenerator; |
||||||
23 | /** @var MailerInterface */ |
||||||
24 | private $mailer; |
||||||
25 | /** @var EventDispatcher */ |
||||||
26 | private $eventDispatcher; |
||||||
27 | /** @var string */ |
||||||
28 | private $redirectRoute = 'redirect_route'; |
||||||
29 | /** @var string */ |
||||||
30 | private $token = 'test_token'; |
||||||
31 | /** @var EmailUpdateConfirmation */ |
||||||
32 | private $emailUpdateConfirmation; |
||||||
33 | /** @var string */ |
||||||
34 | private $emailTest = '[email protected]'; |
||||||
35 | /** @var User */ |
||||||
36 | private $user; |
||||||
37 | private $cypher_method = 'AES-128-CBC'; |
||||||
38 | |||||||
39 | /** @var ValidatorInterface */ |
||||||
40 | private $emailValidator; |
||||||
41 | /** @var ConstraintViolationList */ |
||||||
42 | private $constraintViolationList; |
||||||
43 | |||||||
44 | protected function setUp() |
||||||
45 | { |
||||||
46 | $this->emailValidator = $this->getMockBuilder('Symfony\Component\Validator\Validator\RecursiveValidator')->disableOriginalConstructor()->getMock(); |
||||||
0 ignored issues
–
show
It seems like
$this->getMockBuilder('S...onstructor()->getMock() of type PHPUnit_Framework_MockObject_MockObject is incompatible with the declared type Symfony\Component\Valida...ator\ValidatorInterface of property $emailValidator .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||||||
47 | $this->constraintViolationList = $this->getMockBuilder('Symfony\Component\Validator\ConstraintViolationList')->disableOriginalConstructor()->getMock(); |
||||||
0 ignored issues
–
show
It seems like
$this->getMockBuilder('S...onstructor()->getMock() of type PHPUnit_Framework_MockObject_MockObject is incompatible with the declared type Symfony\Component\Valida...ConstraintViolationList of property $constraintViolationList .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||||||
48 | |||||||
49 | $this->provider = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface')->getMock(); |
||||||
0 ignored issues
–
show
It seems like
$this->getMockBuilder('S...rInterface')->getMock() of type PHPUnit_Framework_MockObject_MockObject is incompatible with the declared type Symfony\Component\Expres...nctionProviderInterface of property $provider .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||||||
50 | $this->user = $this->getMockBuilder('FOS\UserBundle\Model\User') |
||||||
0 ignored issues
–
show
It seems like
$this->getMockBuilder('F...onstructor()->getMock() of type PHPUnit_Framework_MockObject_MockObject is incompatible with the declared type FOS\UserBundle\Model\User of property $user .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||||||
51 | ->disableOriginalConstructor() |
||||||
52 | ->getMock(); |
||||||
53 | $this->router = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Routing\Router') |
||||||
0 ignored issues
–
show
It seems like
$this->getMockBuilder('S...onstructor()->getMock() of type PHPUnit_Framework_MockObject_MockObject is incompatible with the declared type Symfony\Component\Routing\RouterInterface of property $router .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||||||
54 | ->disableOriginalConstructor() |
||||||
55 | ->getMock(); |
||||||
56 | |||||||
57 | $this->tokenGenerator = $this->getMockBuilder('FOS\UserBundle\Util\TokenGenerator')->disableOriginalConstructor()->getMock(); |
||||||
0 ignored issues
–
show
It seems like
$this->getMockBuilder('F...onstructor()->getMock() of type PHPUnit_Framework_MockObject_MockObject is incompatible with the declared type FOS\UserBundle\Util\TokenGenerator of property $tokenGenerator .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||||||
58 | $this->mailer = $this->getMockBuilder('Azine\EmailUpdateConfirmationBundle\Mailer\AzineEmailUpdateConfirmationMailer')->disableOriginalConstructor()->getMock(); |
||||||
0 ignored issues
–
show
It seems like
$this->getMockBuilder('A...onstructor()->getMock() of type PHPUnit_Framework_MockObject_MockObject is incompatible with the declared type FOS\UserBundle\Mailer\MailerInterface of property $mailer .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||||||
59 | $this->eventDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); |
||||||
0 ignored issues
–
show
It seems like
$this->getMockBuilder('S...rInterface')->getMock() of type PHPUnit_Framework_MockObject_MockObject is incompatible with the declared type Symfony\Component\EventDispatcher\EventDispatcher of property $eventDispatcher .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||||||
60 | |||||||
61 | $this->emailUpdateConfirmation = new EmailUpdateConfirmation($this->router, $this->tokenGenerator, $this->mailer, $this->eventDispatcher, $this->emailValidator, $this->redirectRoute, $this->cypher_method); |
||||||
62 | |||||||
63 | $this->user->expects($this->any()) |
||||||
64 | ->method('getConfirmationToken') |
||||||
65 | ->will($this->returnValue($this->token)); |
||||||
66 | } |
||||||
67 | |||||||
68 | public function testFetchEncryptedEmailFromConfirmationLinkMethod() |
||||||
69 | { |
||||||
70 | $this->emailValidator->expects($this->once())->method('validate')->will($this->returnValue($this->constraintViolationList)); |
||||||
0 ignored issues
–
show
The method
expects() does not exist on Symfony\Component\Valida...ator\ValidatorInterface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||||
71 | $encryptedEmail = $this->emailUpdateConfirmation->encryptEmailValue($this->token, $this->emailTest); |
||||||
72 | |||||||
73 | $email = $this->emailUpdateConfirmation->fetchEncryptedEmailFromConfirmationLink($this->user, $encryptedEmail); |
||||||
74 | $this->assertSame($this->emailTest, $email); |
||||||
75 | } |
||||||
76 | |||||||
77 | public function testEncryptDecryptEmail() |
||||||
78 | { |
||||||
79 | $this->emailValidator->expects($this->once())->method('validate')->will($this->returnValue($this->constraintViolationList)); |
||||||
80 | $encryptedEmail = $this->emailUpdateConfirmation->encryptEmailValue($this->user->getConfirmationToken(), $this->emailTest); |
||||||
81 | $this->assertSame($this->emailTest, $this->emailUpdateConfirmation->decryptEmailValue($this->user->getConfirmationToken(), $encryptedEmail)); |
||||||
82 | } |
||||||
83 | |||||||
84 | /** |
||||||
85 | * @expectedException \InvalidArgumentException |
||||||
86 | */ |
||||||
87 | public function testDecryptFromWrongEmailFormat() |
||||||
88 | { |
||||||
89 | $this->emailValidator->expects($this->once())->method('validate')->will($this->returnValue($this->constraintViolationList)); |
||||||
90 | |||||||
91 | $this->constraintViolationList->expects($this->once())->method('count')->will($this->returnValue(1)); |
||||||
0 ignored issues
–
show
The method
expects() does not exist on Symfony\Component\Valida...ConstraintViolationList .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||||
92 | $wrongEmail = 'fooexample.com'; |
||||||
93 | |||||||
94 | $encryptedEmail = $this->emailUpdateConfirmation->encryptEmailValue($this->user->getConfirmationToken(), $wrongEmail); |
||||||
95 | $this->emailUpdateConfirmation->decryptEmailValue($this->user->getConfirmationToken(), $encryptedEmail); |
||||||
96 | } |
||||||
97 | |||||||
98 | /** |
||||||
99 | * @expectedException \InvalidArgumentException |
||||||
100 | */ |
||||||
101 | public function testIntegerIsSetInsteadOfEmailString() |
||||||
102 | { |
||||||
103 | $this->emailUpdateConfirmation->encryptEmailValue($this->user->getConfirmationToken(), 123); |
||||||
104 | } |
||||||
105 | |||||||
106 | /** |
||||||
107 | * @expectedException \InvalidArgumentException |
||||||
108 | */ |
||||||
109 | public function testIntegerIsSetInsteadOfConfirmationTokenStringForEncryption() |
||||||
110 | { |
||||||
111 | $this->emailUpdateConfirmation->encryptEmailValue(123, $this->emailTest); |
||||||
112 | } |
||||||
113 | |||||||
114 | /** |
||||||
115 | * @expectedException \InvalidArgumentException |
||||||
116 | */ |
||||||
117 | public function testIntegerIsSetInsteadOfConfirmationTokenStringForDecryption() |
||||||
118 | { |
||||||
119 | $this->emailUpdateConfirmation->decryptEmailValue(123, $this->emailTest); |
||||||
120 | } |
||||||
121 | } |
||||||
122 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths