These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the Sylius package. |
||
5 | * |
||
6 | * (c) Paweł Jędrzejewski |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | declare(strict_types=1); |
||
13 | |||
14 | namespace spec\Sylius\Behat\Service; |
||
15 | |||
16 | use PhpSpec\ObjectBehavior; |
||
17 | use Prophecy\Argument; |
||
18 | use Sylius\Behat\Service\SecurityServiceInterface; |
||
19 | use Sylius\Behat\Service\SharedSecurityService; |
||
20 | use Sylius\Behat\Service\SharedSecurityServiceInterface; |
||
21 | use Sylius\Component\Core\Model\AdminUserInterface; |
||
22 | use Sylius\Component\Order\Model\OrderInterface; |
||
23 | use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; |
||
24 | use Symfony\Component\Security\Core\Exception\TokenNotFoundException; |
||
25 | |||
26 | final class SharedSecurityServiceSpec extends ObjectBehavior |
||
27 | { |
||
28 | function let(SecurityServiceInterface $adminSecurityService) |
||
29 | { |
||
30 | $this->beConstructedWith($adminSecurityService); |
||
31 | } |
||
32 | |||
33 | function it_is_initializable() |
||
34 | { |
||
35 | $this->shouldHaveType(SharedSecurityService::class); |
||
36 | } |
||
37 | |||
38 | function it_implements_shared_security_service() |
||
39 | { |
||
40 | $this->shouldImplement(SharedSecurityServiceInterface::class); |
||
41 | } |
||
42 | |||
43 | function it_performs_action_as_given_admin_user_and_restore_previous_token( |
||
44 | SecurityServiceInterface $adminSecurityService, |
||
45 | TokenInterface $token, |
||
46 | OrderInterface $order, |
||
47 | AdminUserInterface $adminUser |
||
48 | ) { |
||
49 | $adminSecurityService->getCurrentToken()->willReturn($token); |
||
50 | $adminSecurityService->logIn($adminUser)->shouldBeCalled(); |
||
51 | $order->completeCheckout()->shouldBeCalled(); |
||
52 | $adminSecurityService->restoreToken($token)->shouldBeCalled(); |
||
53 | $adminSecurityService->logOut()->shouldNotBeCalled(); |
||
54 | |||
55 | $wrappedOrder = $order->getWrappedObject(); |
||
0 ignored issues
–
show
|
|||
56 | $this->performActionAsAdminUser( |
||
57 | $adminUser, |
||
58 | function () use ($wrappedOrder) { |
||
59 | $wrappedOrder->completeCheckout(); |
||
60 | } |
||
61 | ); |
||
62 | } |
||
63 | |||
64 | function it_performs_action_as_given_admin_user_and_logout( |
||
65 | SecurityServiceInterface $adminSecurityService, |
||
66 | OrderInterface $order, |
||
67 | AdminUserInterface $adminUser |
||
68 | ) { |
||
69 | $adminSecurityService->getCurrentToken()->willThrow(TokenNotFoundException::class); |
||
70 | $adminSecurityService->logIn($adminUser)->shouldBeCalled(); |
||
71 | $order->completeCheckout()->shouldBeCalled(); |
||
72 | $adminSecurityService->restoreToken(Argument::any())->shouldNotBeCalled(); |
||
73 | $adminSecurityService->logOut()->shouldBeCalled(); |
||
74 | |||
75 | $wrappedOrder = $order->getWrappedObject(); |
||
0 ignored issues
–
show
The method
getWrappedObject() does not seem to exist on object<Sylius\Component\...r\Model\OrderInterface> .
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.
Loading history...
|
|||
76 | $this->performActionAsAdminUser( |
||
77 | $adminUser, |
||
78 | function () use ($wrappedOrder) { |
||
79 | $wrappedOrder->completeCheckout(); |
||
80 | } |
||
81 | ); |
||
82 | } |
||
83 | } |
||
84 |
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.