Skip to content

Commit

Permalink
Make it work with ApiTestCase v3
Browse files Browse the repository at this point in the history
  • Loading branch information
pamil committed Aug 20, 2018
1 parent aea0f6c commit 486ea45
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"php": "^7.1",

"sylius/sylius": "^1.1",
"league/tactician-bundle": "^0.4",
"league/tactician-bundle": "^1.1",
"league/tactician-doctrine": "^1.1"
},
"require-dev": {
"lakion/api-test-case": "^1.2",
"lakion/api-test-case": "^3.1",
"phpspec/phpspec": "^5.0",
"lexik/jwt-authentication-bundle": "^2.5",
"matthiasnoback/symfony-config-test": "^3.1",
Expand All @@ -27,7 +27,8 @@
"autoload-dev": {
"psr-4": {
"Tests\\Sylius\\ShopApiPlugin\\": "tests/"
}
},
"classmap": ["tests/Application/app/AppKernel.php"]
},
"suggest": {
"nelmio/cors-bundle": "allows you to send Cross-Origin Ajax API Request"
Expand Down
7 changes: 3 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.5/phpunit.xsd"
backupGlobals="false"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
>
Expand All @@ -14,8 +12,9 @@
</testsuites>

<php>
<server name="KERNEL_CLASS_PATH" value="/tests/Application/app/AppKernel.php" />
<server name="KERNEL_CLASS" value="AppKernel" />
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
<server name="ESCAPE_JSON" value="true" />
</php>

<filter>
Expand Down
7 changes: 6 additions & 1 deletion tests/Application/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class AppKernel extends Kernel
*/
public function registerBundles(): array
{
return array_merge(parent::registerBundles(), [
$bundles = array_merge(parent::registerBundles(), [
new \Sylius\Bundle\AdminBundle\SyliusAdminBundle(),
new \Sylius\Bundle\ShopBundle\SyliusShopBundle(),

Expand All @@ -22,7 +22,12 @@ public function registerBundles(): array

new \Sylius\ShopApiPlugin\ShopApiPlugin(),
new \Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle(),

new \Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle(),
new \Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle(),
]);

return $bundles;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/Application/app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ swiftmailer:
spool:
type: file
path: "%kernel.cache_dir%/spool"

fidry_alice_data_fixtures:
default_purge_mode: no_purge
db_drivers:
doctrine_orm: true
14 changes: 9 additions & 5 deletions tests/Application/app/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ security:
switch_user: true
context: admin
pattern: "%sylius.security.admin_regex%"
provider: sylius_admin_user_provider
form_login:
provider: sylius_admin_user_provider
login_path: sylius_admin_login
Expand Down Expand Up @@ -49,9 +50,10 @@ security:

api:
pattern: "%sylius.security.api_regex%"
fos_oauth: true
stateless: true
anonymous: true
provider: sylius_admin_user_provider
fos_oauth: true
stateless: true
anonymous: true

shop_api_login:
pattern: "%shop_api.security.regex%/login"
Expand All @@ -67,16 +69,18 @@ security:

shop_api:
pattern: "%shop_api.security.regex%"
stateless: true
anonymous: true
stateless: true
anonymous: true
guard:
provider: sylius_shop_user_provider
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator

shop:
switch_user: { role: ROLE_ALLOWED_TO_SWITCH }
context: shop
pattern: "%sylius.security.shop_regex%"
provider: sylius_shop_user_provider
form_login:
success_handler: sylius.authentication.success_handler
failure_handler: sylius.authentication.failure_handler
Expand Down

0 comments on commit 486ea45

Please sign in to comment.