Skip to content

Commit

Permalink
Make PHPUnit package tests great again
Browse files Browse the repository at this point in the history
  • Loading branch information
pamil committed Apr 30, 2018
1 parent fadf23e commit 2b7c92d
Show file tree
Hide file tree
Showing 93 changed files with 263 additions and 869 deletions.
1 change: 0 additions & 1 deletion phpunit.xml.dist
Expand Up @@ -2,7 +2,6 @@

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php">
<testsuites>
Expand Down
6 changes: 3 additions & 3 deletions src/Sylius/Bundle/AddressingBundle/composer.json
Expand Up @@ -48,9 +48,9 @@
},
"autoload-dev": {
"psr-4": {
"Sylius\\Bundle\\AddressingBundle\\spec\\": "spec/",
"AppBundle\\": "test/src/AppBundle/"
}
"Sylius\\Bundle\\AddressingBundle\\spec\\": "spec/"
},
"classmap": ["test/app/AppKernel.php"]
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
6 changes: 2 additions & 4 deletions src/Sylius/Bundle/AddressingBundle/phpunit.xml.dist
Expand Up @@ -2,14 +2,12 @@

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="test/app/autoload.php"
>
<php>
<server name="KERNEL_DIR" value="test/app/" />
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
<server name="KERNEL_CLASS" value="AppKernel" />
</php>

<testsuites>
<testsuite name="SyliusAddressingBundle Test Suite">
<directory>./test/</directory>
Expand Down
30 changes: 0 additions & 30 deletions src/Sylius/Bundle/AddressingBundle/test/app/autoload.php

This file was deleted.

Expand Up @@ -13,10 +13,12 @@

namespace Sylius\Bundle\AddressingBundle\Tests;

use PHPUnit\Framework\Assert;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;

class SyliusAddressingBundleTest extends WebTestCase
final class SyliusAddressingBundleTest extends WebTestCase
{
/**
* @test
Expand All @@ -33,7 +35,7 @@ public function its_services_are_initializable(): void
});

foreach ($services as $id) {
$container->get($id);
Assert::assertNotNull($container->get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE));
}
}
}
2 changes: 1 addition & 1 deletion src/Sylius/Bundle/AdminBundle/composer.json
Expand Up @@ -28,8 +28,8 @@
"symfony/framework-bundle": "^3.4|^4.0"
},
"require-dev": {
"phpunit/phpunit": "^6.5",
"phpspec/phpspec": "^4.0",
"phpunit/phpunit": "^6.5",
"symfony/dependency-injection": "^3.4|^4.0"
},
"conflict": {
Expand Down
5 changes: 1 addition & 4 deletions src/Sylius/Bundle/AdminBundle/phpunit.xml.dist
@@ -1,15 +1,12 @@
<?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/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="SyliusAdminBundle Test Suite">
<directory>./Tests</directory>
<directory>./Tests/</directory>
</testsuite>
</testsuites>
</phpunit>
6 changes: 3 additions & 3 deletions src/Sylius/Bundle/AttributeBundle/composer.json
Expand Up @@ -46,9 +46,9 @@
},
"autoload-dev": {
"psr-4": {
"Sylius\\Bundle\\AttributeBundle\\spec\\": "spec/",
"AppBundle\\": "test/src/AppBundle/"
}
"Sylius\\Bundle\\AttributeBundle\\spec\\": "spec/"
},
"classmap": ["test/app/AppKernel.php"]
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
7 changes: 3 additions & 4 deletions src/Sylius/Bundle/AttributeBundle/phpunit.xml.dist
Expand Up @@ -2,17 +2,16 @@

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="test/app/autoload.php"
>
<php>
<server name="KERNEL_DIR" value="test/app/" />
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
<server name="KERNEL_CLASS" value="AppKernel" />
</php>

<testsuites>
<testsuite name="SyliusAttributeBundle Test Suite">
<directory>./test/</directory>
<directory>./Tests/</directory>
</testsuite>
</testsuites>
</phpunit>
30 changes: 0 additions & 30 deletions src/Sylius/Bundle/AttributeBundle/test/app/autoload.php

This file was deleted.

Expand Up @@ -13,7 +13,9 @@

namespace Sylius\Bundle\AttributeBundle\Tests;

use PHPUnit\Framework\Assert;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;

final class SyliusAttributeBundleTest extends WebTestCase
Expand All @@ -23,17 +25,17 @@ final class SyliusAttributeBundleTest extends WebTestCase
*/
public function its_services_are_initializable(): void
{
/** @var ContainerInterface $container */
/** @var ContainerBuilder $container */
$container = self::createClient()->getContainer();

$services = $container->getServiceIds();

$services = array_filter($services, function ($serviceId) {
$services = array_filter($services, function (string $serviceId): bool {
return 0 === strpos($serviceId, 'sylius.');
});

foreach ($services as $id) {
$container->get($id);
Assert::assertNotNull($container->get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE));
}
}
}
6 changes: 3 additions & 3 deletions src/Sylius/Bundle/ChannelBundle/composer.json
Expand Up @@ -45,9 +45,9 @@
},
"autoload-dev": {
"psr-4": {
"Sylius\\Bundle\\ChannelBundle\\spec\\": "spec/",
"AppBundle\\": "test/src/AppBundle/"
}
"Sylius\\Bundle\\ChannelBundle\\spec\\": "spec/"
},
"classmap": ["test/app/AppKernel.php"]
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
21 changes: 3 additions & 18 deletions src/Sylius/Bundle/ChannelBundle/phpunit.xml.dist
@@ -1,32 +1,17 @@
<?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/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
>
<php>
<server name="KERNEL_DIR" value="test/app/" />
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
<server name="KERNEL_CLASS" value="AppKernel" />
</php>

<testsuites>
<testsuite name="Sylius Test Suite">
<directory>Tests</directory>
</testsuite>

<testsuite name="SyliusAttributeBundle Test Suite">
<testsuite name="SyliusChannelBundle Test Suite">
<directory>./test/</directory>
<directory>./Tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<exclude>
<directory>Resources</directory>
<directory>Tests</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
30 changes: 0 additions & 30 deletions src/Sylius/Bundle/ChannelBundle/test/app/autoload.php

This file was deleted.

Expand Up @@ -13,27 +13,29 @@

namespace Sylius\Bundle\ChannelBundle\Tests;

use PHPUnit\Framework\Assert;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;

class SyliusChannelBundleTest extends WebTestCase
final class SyliusChannelBundleTest extends WebTestCase
{
/**
* @test
*/
public function its_services_are_initializable()
public function its_services_are_initializable(): void
{
/** @var ContainerInterface $container */
/** @var ContainerBuilder $container */
$container = self::createClient()->getContainer();

$services = $container->getServiceIds();

$services = array_filter($services, function ($serviceId) {
$services = array_filter($services, function (string $serviceId): bool {
return 0 === strpos($serviceId, 'sylius.');
});

foreach ($services as $id) {
$container->get($id);
Assert::assertNotNull($container->get($id, ContainerInterface::NULL_ON_INVALID_REFERENCE));
}
}
}
Expand Up @@ -13,6 +13,7 @@

namespace Sylius\Bundle\CoreBundle\Tests\Application;

use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;
use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait;
use Symfony\Component\HttpKernel\Bundle\Bundle;
Expand All @@ -24,8 +25,10 @@ final class SyliusPluginTraitTest extends TestCase
*/
public function it_does_not_crash(): void
{
new class() extends Bundle {
$class = new class() extends Bundle {
use SyliusPluginTrait;
};

Assert::assertNotNull($class);
}
}
8 changes: 0 additions & 8 deletions src/Sylius/Bundle/CoreBundle/phpunit.xml.dist
Expand Up @@ -3,19 +3,11 @@
<!-- 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/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Sylius Test Suite">
<directory>./Tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./Tests</directory>
</whitelist>
</filter>
</phpunit>
6 changes: 3 additions & 3 deletions src/Sylius/Bundle/CurrencyBundle/composer.json
Expand Up @@ -48,9 +48,9 @@
},
"autoload-dev": {
"psr-4": {
"Sylius\\Bundle\\CurrencyBundle\\spec\\": "spec/",
"AppBundle\\": "test/src/AppBundle/"
}
"Sylius\\Bundle\\CurrencyBundle\\spec\\": "spec/"
},
"classmap": ["test/app/AppKernel.php"]
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
6 changes: 2 additions & 4 deletions src/Sylius/Bundle/CurrencyBundle/phpunit.xml.dist
Expand Up @@ -2,14 +2,12 @@

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="test/app/autoload.php"
>
<php>
<server name="KERNEL_DIR" value="test/app/" />
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
<server name="KERNEL_CLASS" value="AppKernel" />
</php>

<testsuites>
<testsuite name="SyliusCurrencyBundle Test Suite">
<directory>./test/</directory>
Expand Down

0 comments on commit 2b7c92d

Please sign in to comment.