Skip to content

Commit

Permalink
Remove types for php 5.6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjantetteroo committed May 30, 2019
1 parent b8562ec commit dfb078d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

namespace Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\FooBundle\DataFixtures;

use Doctrine\Bundle\MongoDBBundle\Fixture\ODMFixtureInterface;
Expand All @@ -10,12 +8,12 @@

class DependentOnRequiredConstructorArgsFixtures implements ODMFixtureInterface, DependentFixtureInterface
{
public function load(ObjectManager $manager) : void
public function load(ObjectManager $manager)
{
// ...
}

public function getDependencies() : array
public function getDependencies()
{
return [RequiredConstructorArgsFixtures::class];
}
Expand Down
6 changes: 2 additions & 4 deletions Tests/Fixtures/FooBundle/DataFixtures/OtherFixtures.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

namespace Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\FooBundle\DataFixtures;

use Doctrine\Bundle\MongoDBBundle\Fixture\FixtureGroupInterface;
Expand All @@ -10,12 +8,12 @@

class OtherFixtures implements ODMFixtureInterface, FixtureGroupInterface
{
public function load(ObjectManager $manager) : void
public function load(ObjectManager $manager)
{
// ...
}

public static function getGroups() : array
public static function getGroups()
{
return ['staging', 'fulfilledDependencyGroup'];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

namespace Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\FooBundle\DataFixtures;

use Doctrine\Bundle\MongoDBBundle\Fixture\ODMFixtureInterface;
Expand All @@ -13,7 +11,7 @@ public function __construct(string $fooRequiredArg)
{
}

public function load(ObjectManager $manager) : void
public function load(ObjectManager $manager)
{
// ...
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

namespace Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\FooBundle\DataFixtures;

use Doctrine\Bundle\MongoDBBundle\Fixture\FixtureGroupInterface;
Expand All @@ -11,17 +9,17 @@

class WithDependenciesFixtures implements ODMFixtureInterface, DependentFixtureInterface, FixtureGroupInterface
{
public function load(ObjectManager $manager) : void
public function load(ObjectManager $manager)
{
// ...
}

public function getDependencies() : array
public function getDependencies()
{
return [OtherFixtures::class];
}

public static function getGroups() : array
public static function getGroups()
{
return ['missingDependencyGroup', 'fulfilledDependencyGroup'];
}
Expand Down
2 changes: 0 additions & 2 deletions Tests/Fixtures/FooBundle/FooBundle.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

namespace Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\FooBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;
Expand Down
51 changes: 24 additions & 27 deletions Tests/IntegrationTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

namespace Doctrine\Bundle\MongoDBBundle\Tests;

use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\FixturesCompilerPass;
Expand All @@ -11,7 +9,6 @@
use Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\FooBundle\DataFixtures\WithDependenciesFixtures;
use Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\FooBundle\FooBundle;
use Doctrine\Common\Persistence\ManagerRegistry;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
Expand All @@ -28,10 +25,10 @@

class IntegrationTest extends TestCase
{
public function testFixturesLoader(): void
public function testFixturesLoader()
{
$kernel = new IntegrationTestKernel('dev', true);
$kernel->addServices(static function (ContainerBuilder $c): void {
$kernel->addServices(static function (ContainerBuilder $c) {
$c->autowire(OtherFixtures::class)
->addTag(FixturesCompilerPass::FIXTURE_TAG);

Expand Down Expand Up @@ -59,12 +56,12 @@ public function testFixturesLoader(): void
$this->assertInstanceOf(WithDependenciesFixtures::class, $actualFixtures[1]);
}

public function testFixturesLoaderWhenFixtureHasDependencyThatIsNotYetLoaded(): void
public function testFixturesLoaderWhenFixtureHasDependencyThatIsNotYetLoaded()
{
// See https://github.com/doctrine/DoctrineFixturesBundle/issues/215

$kernel = new IntegrationTestKernel('dev', true);
$kernel->addServices(static function (ContainerBuilder $c): void {
$kernel->addServices(static function (ContainerBuilder $c) {
$c->autowire(WithDependenciesFixtures::class)
->addTag(FixturesCompilerPass::FIXTURE_TAG);

Expand Down Expand Up @@ -96,10 +93,10 @@ public function testFixturesLoaderWhenFixtureHasDependencyThatIsNotYetLoaded():
* @expectedException \LogicException
* @expectedExceptionMessage The "Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\FooBundle\DataFixtures\RequiredConstructorArgsFixtures" fixture class is trying to be loaded, but is not available. Make sure this class is defined as a service and tagged with "doctrine.fixture.odm.mongodb".
*/
public function testExceptionIfDependentFixtureNotWired(): void
public function testExceptionIfDependentFixtureNotWired()
{
$kernel = new IntegrationTestKernel('dev', true);
$kernel->addServices(static function (ContainerBuilder $c): void {
$kernel->addServices(static function (ContainerBuilder $c) {
$c->autowire(DependentOnRequiredConstructorArgsFixtures::class)
->addTag(FixturesCompilerPass::FIXTURE_TAG);

Expand All @@ -114,10 +111,10 @@ public function testExceptionIfDependentFixtureNotWired(): void
$loader->getFixtures();
}

public function testFixturesLoaderWithGroupsOptionViaInterface(): void
public function testFixturesLoaderWithGroupsOptionViaInterface()
{
$kernel = new IntegrationTestKernel('dev', true);
$kernel->addServices(static function (ContainerBuilder $c): void {
$kernel->addServices(static function (ContainerBuilder $c) {
// has a "staging" group via the getGroups() method
$c->autowire(OtherFixtures::class)
->addTag(FixturesCompilerPass::FIXTURE_TAG);
Expand Down Expand Up @@ -146,10 +143,10 @@ public function testFixturesLoaderWithGroupsOptionViaInterface(): void
$this->assertInstanceOf(OtherFixtures::class, $actualFixtures[0]);
}

public function testFixturesLoaderWithGroupsOptionViaTag(): void
public function testFixturesLoaderWithGroupsOptionViaTag()
{
$kernel = new IntegrationTestKernel('dev', true);
$kernel->addServices(static function (ContainerBuilder $c): void {
$kernel->addServices(static function (ContainerBuilder $c) {
// has a "staging" group via the getGroups() method
$c->autowire(OtherFixtures::class)
->addTag(FixturesCompilerPass::FIXTURE_TAG, ['group' => 'group1'])
Expand All @@ -173,10 +170,10 @@ public function testFixturesLoaderWithGroupsOptionViaTag(): void
$this->assertCount(0, $loader->getFixtures(['group3']));
}

public function testLoadFixturesViaGroupWithMissingDependency(): void
public function testLoadFixturesViaGroupWithMissingDependency()
{
$kernel = new IntegrationTestKernel('dev', true);
$kernel->addServices(static function (ContainerBuilder $c): void {
$kernel->addServices(static function (ContainerBuilder $c) {
// has a "staging" group via the getGroups() method
$c->autowire(OtherFixtures::class)
->addTag(FixturesCompilerPass::FIXTURE_TAG);
Expand All @@ -199,10 +196,10 @@ public function testLoadFixturesViaGroupWithMissingDependency(): void
$loader->getFixtures(['missingDependencyGroup']);
}

public function testLoadFixturesViaGroupWithFulfilledDependency(): void
public function testLoadFixturesViaGroupWithFulfilledDependency()
{
$kernel = new IntegrationTestKernel('dev', true);
$kernel->addServices(static function (ContainerBuilder $c): void {
$kernel->addServices(static function (ContainerBuilder $c) {
// has a "staging" group via the getGroups() method
$c->autowire(OtherFixtures::class)
->addTag(FixturesCompilerPass::FIXTURE_TAG);
Expand Down Expand Up @@ -232,10 +229,10 @@ public function testLoadFixturesViaGroupWithFulfilledDependency(): void
], $actualFixtureClasses);
}

public function testLoadFixturesByShortName(): void
public function testLoadFixturesByShortName()
{
$kernel = new IntegrationTestKernel('dev', true);
$kernel->addServices(static function (ContainerBuilder $c): void {
$kernel->addServices(static function (ContainerBuilder $c) {
// has a "staging" group via the getGroups() method
$c->autowire(OtherFixtures::class)
->addTag(FixturesCompilerPass::FIXTURE_TAG);
Expand Down Expand Up @@ -275,19 +272,19 @@ class IntegrationTestKernel extends Kernel
/** @var int */
private $randomKey;

public function __construct(string $environment, bool $debug)
public function __construct($environment, $debug)
{
$this->randomKey = rand(100, 999);

parent::__construct($environment, $debug);
}

protected function getContainerClass(): string
protected function getContainerClass()
{
return 'test' . $this->randomKey . parent::getContainerClass();
}

public function registerBundles(): array
public function registerBundles()
{
return [
new FrameworkBundle(),
Expand All @@ -296,29 +293,29 @@ public function registerBundles(): array
];
}

public function addServices(callable $callback): void
public function addServices(callable $callback)
{
$this->servicesCallback = $callback;
}

protected function configureRoutes(RouteCollectionBuilder $routes): void
protected function configureRoutes(RouteCollectionBuilder $routes)
{
}

protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader): void
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
{
$c->setParameter('kernel.secret', 'foo');
$c->register('doctrine', ManagerRegistry::class);
$callback = $this->servicesCallback;
$callback($c);
}

public function getCacheDir(): string
public function getCacheDir()
{
return sys_get_temp_dir() . '/doctrine_mongodb_odm_bundle' . $this->randomKey;
}

public function getLogDir(): string
public function getLogDir()
{
return sys_get_temp_dir();
}
Expand Down

0 comments on commit dfb078d

Please sign in to comment.