mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Fix Phpspec tests
This commit is contained in:
parent
20985e6ffd
commit
2d29a2e79e
9 changed files with 20 additions and 16 deletions
|
|
@ -26,7 +26,7 @@ use Sylius\Component\Resource\Repository\RepositoryInterface;
|
|||
use Sylius\Component\User\Canonicalizer\CanonicalizerInterface;
|
||||
use Sylius\Component\User\Model\UserOAuthInterface;
|
||||
use Sylius\Component\User\Repository\UserRepositoryInterface;
|
||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||
use SyliusLabs\Polyfill\Symfony\Security\Core\Exception\UserNotFoundException;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ class UserProvider extends BaseUserProvider implements AccountConnectorInterface
|
|||
return $this->createUserByOAuthUserResponse($response);
|
||||
}
|
||||
|
||||
throw new UsernameNotFoundException('Email is null or not provided');
|
||||
throw new UserNotFoundException('Email is null or not provided');
|
||||
}
|
||||
|
||||
public function connect(UserInterface $user, UserResponseInterface $response): void
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ final class UriBasedSectionProvider implements SectionProviderInterface
|
|||
|
||||
public function getSection(): ?SectionInterface
|
||||
{
|
||||
$request = $this->requestStack->getMasterRequest();
|
||||
$request = $this->requestStack->getMainRequest();
|
||||
if (null === $request) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
"sylius/inventory-bundle": "^1.6",
|
||||
"sylius/locale-bundle": "^1.6",
|
||||
"sylius/money-bundle": "^1.6",
|
||||
"sylius/order-bundle": "^1.6",
|
||||
"sylius/order-bundle": "^1.6 || dev-symfony-6",
|
||||
"sylius/payment-bundle": "^1.6",
|
||||
"sylius/payum-bundle": "^1.6",
|
||||
"sylius/product-bundle": "^1.6",
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
"sylius/shipping-bundle": "^1.6",
|
||||
"sylius/taxation-bundle": "^1.6",
|
||||
"sylius/taxonomy-bundle": "^1.6",
|
||||
"sylius/theme-bundle": "^2.1.1 || dev-symfony-6",
|
||||
"sylius/theme-bundle": "^2.1.1 || dev-symfony6",
|
||||
"sylius/ui-bundle": "^1.6",
|
||||
"sylius/user-bundle": "^1.6 || dev-symfony-6",
|
||||
"symfony/framework-bundle": "^5.4 || ^6.0",
|
||||
|
|
@ -73,7 +73,7 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"doctrine/doctrine-bundle": "^1.12 || ^2.0",
|
||||
"hwi/oauth-bundle": "^1.1",
|
||||
"hwi/oauth-bundle": "^1.1 || ^2.0@beta",
|
||||
"matthiasnoback/symfony-config-test": "^4.2",
|
||||
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
|
||||
"phpspec/phpspec": "^7.2",
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use Sylius\Component\Core\Model\ShopUserInterface;
|
|||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
final class CustomerContextSpec extends ObjectBehavior
|
||||
{
|
||||
|
|
@ -53,7 +54,7 @@ final class CustomerContextSpec extends ObjectBehavior
|
|||
TokenStorageInterface $tokenStorage,
|
||||
AuthorizationCheckerInterface $authorizationChecker,
|
||||
TokenInterface $token,
|
||||
\stdClass $user,
|
||||
UserInterface $user,
|
||||
): void {
|
||||
$tokenStorage->getToken()->willReturn($token);
|
||||
$authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')->willReturn(true);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ final class AddBaseCurrencySubscriberSpec extends ObjectBehavior
|
|||
|
||||
$form
|
||||
->add('baseCurrency', Argument::type('string'), Argument::withEntry('disabled', true))
|
||||
->willReturn($form)
|
||||
->shouldBeCalled()
|
||||
;
|
||||
|
||||
|
|
@ -64,6 +65,7 @@ final class AddBaseCurrencySubscriberSpec extends ObjectBehavior
|
|||
|
||||
$form
|
||||
->add('baseCurrency', Argument::type('string'), Argument::withEntry('disabled', false))
|
||||
->willReturn($form)
|
||||
->shouldBeCalled()
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ final class AddUserFormSubscriberSpec extends ObjectBehavior
|
|||
): void {
|
||||
$event->getForm()->willReturn($form);
|
||||
|
||||
$form->add('user', '\Fully\Qualified\ClassName', Argument::type('array'))->shouldBeCalled();
|
||||
$form->add('createUser', Argument::type('string'), Argument::type('array'))->shouldBeCalled();
|
||||
$form->add('user', '\Fully\Qualified\ClassName', Argument::type('array'))->willReturn($form)->shouldBeCalled();
|
||||
$form->add('createUser', Argument::type('string'), Argument::type('array'))->willReturn($form)->shouldBeCalled();
|
||||
|
||||
$this->preSetData($event);
|
||||
}
|
||||
|
|
@ -64,8 +64,8 @@ final class AddUserFormSubscriberSpec extends ObjectBehavior
|
|||
$customer->setUser(null)->shouldBeCalled();
|
||||
$event->setData($customer)->shouldBeCalled();
|
||||
|
||||
$form->remove('user')->shouldBeCalled();
|
||||
$form->add('user', '\Fully\Qualified\ClassName', Argument::type('array'))->shouldBeCalled();
|
||||
$form->remove('user')->willReturn($form)->shouldBeCalled();
|
||||
$form->add('user', '\Fully\Qualified\ClassName', Argument::type('array'))->willReturn($form)->shouldBeCalled();
|
||||
|
||||
$this->submit($event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ final class CustomerRegistrationFormSubscriberSpec extends ObjectBehavior
|
|||
$customer->getUser()->willReturn($user);
|
||||
|
||||
$existingCustomer->setUser($user)->shouldBeCalled();
|
||||
$form->setData($existingCustomer)->shouldBeCalled();
|
||||
$form->setData($existingCustomer)->willReturn($form)->shouldBeCalled();
|
||||
|
||||
$this->preSubmit($event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use Sylius\Component\Resource\Repository\RepositoryInterface;
|
|||
use Sylius\Component\User\Canonicalizer\CanonicalizerInterface;
|
||||
use Sylius\Component\User\Model\UserOAuthInterface;
|
||||
use Sylius\Component\User\Repository\UserRepositoryInterface;
|
||||
use SyliusLabs\Polyfill\Symfony\Security\Core\Exception\UserNotFoundException;
|
||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
|
@ -223,7 +224,7 @@ final class UserProviderSpec extends ObjectBehavior
|
|||
$response->getEmail()->willReturn(null);
|
||||
$userRepository->findOneByEmail(Argument::any())->shouldNotBeCalled();
|
||||
|
||||
$this->shouldThrow(UsernameNotFoundException::class)->during('loadUserByOAuthUserResponse', [$response]);
|
||||
$this->shouldThrow(UserNotFoundException::class)->during('loadUserByOAuthUserResponse', [$response]);
|
||||
}
|
||||
|
||||
function it_should_throw_exception_when_unsupported_user_is_used(
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ final class UriBasedSectionProviderSpec extends ObjectBehavior
|
|||
UriBasedSectionResolverInterface $firstSectionResolver,
|
||||
SectionInterface $section,
|
||||
): void {
|
||||
$requestStack->getMasterRequest()->willReturn($request);
|
||||
$requestStack->getMainRequest()->willReturn($request);
|
||||
|
||||
$request->getPathInfo()->willReturn('/something');
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ final class UriBasedSectionProviderSpec extends ObjectBehavior
|
|||
UriBasedSectionResolverInterface $secondSectionResolver,
|
||||
SectionInterface $section,
|
||||
): void {
|
||||
$requestStack->getMasterRequest()->willReturn($request);
|
||||
$requestStack->getMainRequest()->willReturn($request);
|
||||
|
||||
$request->getPathInfo()->willReturn('/something');
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ final class UriBasedSectionProviderSpec extends ObjectBehavior
|
|||
|
||||
function it_return_null_if_master_request_has_not_been_resolved(RequestStack $requestStack): void
|
||||
{
|
||||
$requestStack->getMasterRequest()->willReturn(null);
|
||||
$requestStack->getMainRequest()->willReturn(null);
|
||||
|
||||
$this->getSection()->shouldReturn(null);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue