Skip to content

Commit

Permalink
Clean up PHPUnit tests a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
pamil committed Feb 19, 2019
1 parent 0547431 commit b4f36c8
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 143 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@
/composer.phar
/composer.lock

/test/var

/phpspec.yml
/phpunit.xml
13 changes: 2 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,7 @@
"matthiasnoback/symfony-config-test": "^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^3.0",
"phpspec/phpspec": "^5.0",
"phpunit/phpunit": "^7.0",
"twig/twig": "^2.0",
"symfony/browser-kit": "^3.4|^4.1.1",
"symfony/dependency-injection": "^3.4|^4.1.1",
"symfony/templating": "^3.4|^4.1.1",
"symfony/translation": "^3.4|^4.1.1",
"symfony/twig-bundle": "^3.4|^4.1.1",
"symfony/security-csrf": "^3.4|^4.1.1",
"polishsymfonycommunity/symfony-mocker-container": "^1.0"
"phpunit/phpunit": "^7.0"
},
"autoload": {
"psr-4": { "Sylius\\Bundle\\FixturesBundle\\": "src/" }
Expand All @@ -52,8 +44,7 @@
"psr-4": {
"Sylius\\Bundle\\FixturesBundle\\spec\\": "spec/",
"Sylius\\Bundle\\FixturesBundle\\Tests\\": "tests/"
},
"classmap": ["test/app/AppKernel.php"]
}
},
"extra": {
"branch-alias": {
Expand Down
3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
colors="true"
>
<php>
<server name="KERNEL_CLASS" value="AppKernel" />
<env name="KERNEL_CLASS" value="Sylius\Bundle\FixturesBundle\Tests\Application\Kernel" />
</php>

<testsuites>
<testsuite name="SyliusFixturesBundle Test Suite">
<directory>./test/</directory>
<directory>./Tests/</directory>
</testsuite>
</testsuites>
Expand Down
60 changes: 0 additions & 60 deletions test/app/AppKernel.php

This file was deleted.

32 changes: 0 additions & 32 deletions test/app/config/config.yml

This file was deleted.

6 changes: 0 additions & 6 deletions test/app/config/parameters.yml

This file was deleted.

24 changes: 0 additions & 24 deletions test/app/console

This file was deleted.

3 changes: 3 additions & 0 deletions tests/Application/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/var/cache
/var/log
/var/db.sql
40 changes: 40 additions & 0 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Bundle\FixturesBundle\Tests\Application;

use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
/**
* {@inheritdoc}
*/
public function registerBundles(): array
{
return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \Sylius\Bundle\FixturesBundle\SyliusFixturesBundle(),
];
}

/**
* {@inheritdoc}
*/
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__ . '/config/config.yml');
}
}
File renamed without changes.
13 changes: 13 additions & 0 deletions tests/Application/config/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
framework:
secret: "Three can keep a secret, if two of them are dead."
test: ~

doctrine:
dbal:
driver: "pdo_sqlite"
path: "%kernel.project_dir%/var/db.sql"
charset: UTF8
orm:
entity_managers:
default:
auto_mapping: true
Empty file.
7 changes: 5 additions & 2 deletions tests/DependencyInjection/SyliusFixturesExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Sylius\Bundle\FixturesBundle\Tests\DependencyInjection;

use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
use PHPUnit\Framework\Assert;
use Sylius\Bundle\FixturesBundle\DependencyInjection\SyliusFixturesExtension;

final class SyliusFixturesExtensionTest extends AbstractExtensionTestCase
Expand All @@ -23,6 +24,8 @@ final class SyliusFixturesExtensionTest extends AbstractExtensionTestCase
*/
public function it_does_not_crash_if_no_suite_is_configured(): void
{
$this->expectNotToPerformAssertions();

$this->load();
}

Expand All @@ -38,8 +41,8 @@ public function it_registers_configured_suites(): void
$suiteRegistryDefinition = $this->container->findDefinition('sylius_fixtures.suite_registry');
$suiteMethodCall = $suiteRegistryDefinition->getMethodCalls()[0];

static::assertSame('addSuite', $suiteMethodCall[0]);
static::assertSame('suite_name', $suiteMethodCall[1][0]);
Assert::assertSame('addSuite', $suiteMethodCall[0]);
Assert::assertSame('suite_name', $suiteMethodCall[1][0]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,28 @@

declare(strict_types=1);

namespace Sylius\Bundle\FixturesBundle\Tests;
namespace Sylius\Bundle\FixturesBundle\Tests\Smoke;

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

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

$services = $container->getServiceIds();

$services = array_filter($services, function (string $serviceId): bool {
return 0 === strpos($serviceId, 'sylius.');
return 0 === strpos($serviceId, 'sylius_fixtures.') || 0 === strpos($serviceId, 'Sylius\\Bundle\\FixturesBundle\\');
});

foreach ($services as $id) {
Expand Down

0 comments on commit b4f36c8

Please sign in to comment.