Skip to content

Commit

Permalink
[ApiBundle] Refactor directories and namespaces of test application
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed Feb 26, 2021
1 parent 035c3a0 commit f40dba3
Show file tree
Hide file tree
Showing 31 changed files with 55 additions and 78 deletions.
1 change: 0 additions & 1 deletion src/Sylius/Bundle/ApiBundle/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

/composer.lock
/.phpunit.result.cache
/test/db.sql
3 changes: 2 additions & 1 deletion src/Sylius/Bundle/ApiBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"autoload-dev": {
"psr-4": {
"Sylius\\Bundle\\ApiBundle\\spec\\": "spec/",
"Sylius\\Bundle\\ApiBundle\\Tests\\": "Tests/"
"Sylius\\Bundle\\ApiBundle\\Tests\\": "Tests/",
"Sylius\\Bundle\\ApiBundle\\Application\\": "test/src/"
}
},
"repositories": [
Expand Down
6 changes: 3 additions & 3 deletions src/Sylius/Bundle/ApiBundle/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
<php>
<ini name="error_reporting" value="-1" />

<server name="KERNEL_CLASS" value="Sylius\Bundle\ApiBundle\test\src\AppKernel" />
<server name="KERNEL_CLASS" value="Sylius\Bundle\ApiBundle\Application\Kernel" />
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
<server name="DATABASE_URL" value="sqlite:///%kernel.project_dir%/db.sql" />
<server name="DATABASE_URL" value="sqlite:///%kernel.project_dir%/var/db.sql" />
<server name="APP_DEBUG" value="0" />
<server name="APP_SECRET" value="ch4mb3r0f5ecr3ts"/>
</php>

<testsuites>
<testsuite name="SyliusApiBundle Test Suite">
<directory>./Tests/</directory>
<directory>./test/tests/</directory>
<directory>./test/Tests/</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion src/Sylius/Bundle/ApiBundle/test/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1 @@
KERNEL_CLASS='Sylius\Bundle\ApiBundle\test\src\AppKernel'
KERNEL_CLASS='Sylius\Bundle\ApiBundle\Application\Kernel'
13 changes: 5 additions & 8 deletions src/Sylius/Bundle/ApiBundle/test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
/public/build
!/public/media/image/.gitkeep

/app/config/parameters.yml

/bin/symfony_requirements

/docs/.doctrees
Expand All @@ -19,16 +17,15 @@

/behat.yml
/phpspec.yml
/test/db.sql

# Symfony CLI https://symfony.com/doc/current/setup/symfony_server.html#different-php-settings-per-project
/.php-version
/php.ini

###> symfony/framework-bundle ###
/.env.*.local
/.env.local
/.env.local.php
.env.*.local
.env.local
.env.local.php
/public/bundles
/var/
/vendor/
Expand All @@ -45,6 +42,6 @@
###< phpunit/phpunit ###

###> lexik/jwt-authentication-bundle ###
/config/jwt/private.pem
/config/jwt/public.pem
/Application/config/jwt/private.pem
/Application/config/jwt/public.pem
###< lexik/jwt-authentication-bundle ###
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Sylius\Bundle\ApiBundle\test\tests;
namespace Sylius\Bundle\ApiBundle\test\Tests;

use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

declare(strict_types=1);

namespace Sylius\Bundle\ApiBundle\test\tests;
namespace Sylius\Bundle\ApiBundle\test\Tests;

use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;
use Sylius\Bundle\ApiBundle\test\src\Entity\Foo;
use Sylius\Bundle\ApiBundle\test\src\Entity\FooSyliusResource;
use Sylius\Bundle\ApiBundle\Application\Entity\Foo;
use Sylius\Bundle\ApiBundle\Application\Entity\FooSyliusResource;
use Sylius\Component\Core\Model\AdminUser;
use Symfony\Contracts\HttpClient\ResponseInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Sylius\Bundle\ApiBundle\test\tests;
namespace Sylius\Bundle\ApiBundle\test\Tests;

use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Sylius\Bundle\ApiBundle\test\tests;
namespace Sylius\Bundle\ApiBundle\test\Tests;

use Fidry\AliceDataFixtures\LoaderInterface;
use Fidry\AliceDataFixtures\Persistence\PurgeMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Sylius\Bundle\ApiBundle\test\tests;
namespace Sylius\Bundle\ApiBundle\test\Tests;

use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;

Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Bundle/ApiBundle/test/bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* file that was distributed with this source code.
*/

use Sylius\Bundle\ApiBundle\test\src\AppKernel;
use Sylius\Bundle\ApiBundle\Application\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\ErrorHandler\Debug;
Expand Down Expand Up @@ -42,6 +42,6 @@ if ($_SERVER['APP_DEBUG']) {
}
}

$kernel = new AppKernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata https://api-platform.com/schema/metadata/metadata-2.0.xsd"
>
<resource class="Sylius\Bundle\ApiBundle\test\src\Entity\Foo" shortName="Foo">
<resource class="Sylius\Bundle\ApiBundle\Application\Entity\Foo" shortName="Foo">
<collectionOperations>
<collectionOperation name="get">
<attribute name="method">GET</attribute>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata https://api-platform.com/schema/metadata/metadata-2.0.xsd"
>
<resource class="Sylius\Bundle\ApiBundle\test\src\Entity\FooSyliusResource" shortName="FooSyliusResource">
<resource class="Sylius\Bundle\ApiBundle\Application\Entity\FooSyliusResource" shortName="FooSyliusResource">
<collectionOperations>
<collectionOperation name="get">
<attribute name="method">GET</attribute>
Expand Down
17 changes: 11 additions & 6 deletions src/Sylius/Bundle/ApiBundle/test/config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
imports:
- { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" }
- { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" }
- { resource: "security.yaml" }

parameters:
locale: en_US
database_driver: pdo_sqlite
database_path: "%kernel.project_dir%/var/db.sql"

api_platform:
mapping:
Expand All @@ -19,7 +25,7 @@ framework:
test: ~
serializer:
mapping:
paths: ['%kernel.project_dir%/src/Resources/serialization']
paths: ['%kernel.project_dir%/config/serialization']

doctrine_migrations:
storage:
Expand All @@ -31,17 +37,16 @@ doctrine:
driver: "%database_driver%"
path: "%database_path%"
charset: UTF8

orm:
entity_managers:
default:
mappings:
test:
mapping: true
type: xml
dir: "%kernel.project_dir%/src/Resources/config/doctrine"
dir: '%kernel.project_dir%/config/doctrine'
alias: ~
prefix: Sylius\Bundle\ApiBundle\test\src\Entity
prefix: Sylius\Bundle\ApiBundle\Application\Entity
is_bundle: false

lexik_jwt_authentication:
Expand All @@ -53,10 +58,10 @@ sylius_taxonomy:
resources:
taxon:
classes:
model: Sylius\Bundle\ApiBundle\test\src\Entity\Taxon
model: Sylius\Bundle\ApiBundle\Application\Entity\Taxon

sylius_resource:
resources:
test.foo_sylius_resource:
classes:
model: Sylius\Bundle\ApiBundle\test\src\Entity\FooSyliusResource
model: Sylius\Bundle\ApiBundle\Application\Entity\FooSyliusResource
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
-->

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping">
<entity name="Sylius\Bundle\ApiBundle\test\src\Entity\Foo" table="foo">
<entity name="Sylius\Bundle\ApiBundle\Application\Entity\Foo" table="foo">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
Expand All @@ -23,7 +23,7 @@
<join-column name="owner_id" referenced-column-name="id" />
</many-to-one>

<many-to-one field="fooSyliusResource" target-entity="Sylius\Bundle\ApiBundle\test\src\Entity\FooSyliusResource">
<many-to-one field="fooSyliusResource" target-entity="Sylius\Bundle\ApiBundle\Application\Entity\FooSyliusResource">
<join-column name="foo_sylius_resource_id" referenced-column-name="id" />
</many-to-one>
</entity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
-->

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping">
<entity name="Sylius\Bundle\ApiBundle\test\src\Entity\FooSyliusResource" table="foo_sylius_resource">
<entity name="Sylius\Bundle\ApiBundle\Application\Entity\FooSyliusResource" table="foo_sylius_resource">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
-->

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping">
<entity name="Sylius\Bundle\ApiBundle\test\src\Entity\Taxon" table="sylius_taxon">
<entity name="Sylius\Bundle\ApiBundle\Application\Entity\Taxon" table="sylius_taxon">
<field name="type" column="type" type="string" />
</entity>
</doctrine-mapping>
4 changes: 2 additions & 2 deletions src/Sylius/Bundle/ApiBundle/test/config/fixtures/foo.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Sylius\Bundle\ApiBundle\test\src\Entity\FooSyliusResource:
Sylius\Bundle\ApiBundle\Application\Entity\FooSyliusResource:
fooSyliusResource3:
name: FooSyliusResource3

Sylius\Bundle\ApiBundle\test\src\Entity\Foo:
Sylius\Bundle\ApiBundle\Application\Entity\Foo:
foo1:
name: Foo0
owner: '@admin'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sylius\Bundle\ApiBundle\test\src\Entity\FooSyliusResource:
Sylius\Bundle\ApiBundle\Application\Entity\FooSyliusResource:
fooSyliusResource1:
name: FooSyliusResource1
fooSyliusResource2:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sylius\Bundle\ApiBundle\test\src\Entity\Taxon:
Sylius\Bundle\ApiBundle\Application\Entity\Taxon:
category:
code: "category"
mugs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/serializer-mapping https://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd"
>
<class name="Sylius\Bundle\ApiBundle\test\src\Entity\Foo">
<class name="Sylius\Bundle\ApiBundle\Application\Entity\Foo">
<attribute name="id">
<group>foo:read</group>
</attribute>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/serializer-mapping https://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd"
>
<class name="Sylius\Bundle\ApiBundle\test\src\Entity\FooSyliusResource">
<class name="Sylius\Bundle\ApiBundle\Application\Entity\FooSyliusResource">
<attribute name="id">
<group>foo-sylius-resource:read</group>
</attribute>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/serializer-mapping https://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd"
>
<class name="Sylius\Bundle\ApiBundle\test\src\Entity\Taxon">
<class name="Sylius\Bundle\ApiBundle\Application\Entity\Taxon">
<attribute name="id">
<group>admin:taxon:read</group>
<group>shop:taxon:read</group>
Expand Down
4 changes: 0 additions & 4 deletions src/Sylius/Bundle/ApiBundle/test/config/services.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions src/Sylius/Bundle/ApiBundle/test/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use Sylius\Bundle\ApiBundle\test\src\AppKernel;
use Sylius\Bundle\ApiBundle\Application\Kernel;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;

Expand All @@ -22,7 +22,7 @@
Request::setTrustedHosts([$trustedHosts]);
}

$kernel = new AppKernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion src/Sylius/Bundle/ApiBundle/test/src/Entity/Foo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Sylius\Bundle\ApiBundle\test\src\Entity;
namespace Sylius\Bundle\ApiBundle\Application\Entity;

use Sylius\Component\Core\Model\AdminUserInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Sylius\Bundle\ApiBundle\test\src\Entity;
namespace Sylius\Bundle\ApiBundle\Application\Entity;

use Sylius\Component\Resource\Model\ResourceInterface;

Expand Down
3 changes: 2 additions & 1 deletion src/Sylius/Bundle/ApiBundle/test/src/Entity/Taxon.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Sylius\Bundle\ApiBundle\test\src\Entity;
namespace Sylius\Bundle\ApiBundle\Application\Entity;

use Sylius\Component\Core\Model\Taxon as BaseTaxon;

Expand All @@ -23,6 +23,7 @@ class Taxon extends BaseTaxon
public function __construct()
{
parent::__construct();

$this->type = 'default';
}

Expand Down
Loading

0 comments on commit f40dba3

Please sign in to comment.