Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up PHPUnit tests a bit #13

Merged
merged 1 commit into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
15 changes: 3 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,10 @@
"matthiasnoback/symfony-config-test": "^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^3.0",
"phpspec/phpspec": "^5.0",
"phpstan/phpstan-phpunit": "^0.10",
"phpstan/phpstan-shim": "^0.10",
"phpunit/phpunit": "^7.0",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"symfony/browser-kit": "^3.4|^4.1.1",
"symfony/dependency-injection": "^3.4|^4.1.1",
"symfony/security-csrf": "^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",
"twig/twig": "^2.0",
"proget-hq/phpstan-phpspec": "^0.1.1",
"phpstan/phpstan-phpunit": "^0.10"
"proget-hq/phpstan-phpspec": "^0.1.1"
},
"autoload": {
"psr-4": { "Sylius\\Bundle\\FixturesBundle\\": "src/" }
Expand All @@ -55,8 +47,7 @@
"psr-4": {
"spec\\Sylius\\Bundle\\FixturesBundle\\": "spec/",
"Sylius\\Bundle\\FixturesBundle\\Tests\\": "tests/"
},
"classmap": ["test/app/AppKernel.php"]
}
},
"scripts": {
"analyse": [
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;

final 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