1
0
mirror of synced 2025-02-13 10:49:25 +03:00

Format commands' tests

To simplify and organise the code (also replacing `$this->assert*`
with `self::assert*`).
This commit is contained in:
Luís Cobucci 2017-11-24 01:13:52 +01:00
parent 8a893068ce
commit 43a88d539d
No known key found for this signature in database
GPG Key ID: EC61C5F01750ED3C
7 changed files with 165 additions and 179 deletions

View File

@ -30,27 +30,24 @@ class ClearCacheCollectionRegionCommandTest extends OrmFunctionalTestCase
$this->enableSecondLevelCache(); $this->enableSecondLevelCache();
parent::setUp(); parent::setUp();
$this->command = new CollectionRegionCommand();
$this->application = new Application(); $this->application = new Application();
$this->command = new CollectionRegionCommand(); $this->application->setHelperSet(new HelperSet(['em' => new EntityManagerHelper($this->_em)]));
$this->application->setHelperSet(new HelperSet(
[
'em' => new EntityManagerHelper($this->_em)
]
));
$this->application->add($this->command); $this->application->add($this->command);
} }
public function testClearAllRegion() public function testClearAllRegion()
{ {
$command = $this->application->find('orm:clear-cache:region:collection'); $command = $this->application->find('orm:clear-cache:region:collection');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'--all' => true, '--all' => true,
], ['decorated' => false] ],
['decorated' => false]
); );
$this->assertEquals('Clearing all second-level cache collection regions' . PHP_EOL, $tester->getDisplay()); $this->assertEquals('Clearing all second-level cache collection regions' . PHP_EOL, $tester->getDisplay());
@ -58,14 +55,16 @@ class ClearCacheCollectionRegionCommandTest extends OrmFunctionalTestCase
public function testClearByOwnerEntityClassName() public function testClearByOwnerEntityClassName()
{ {
$command = $this->application->find('orm:clear-cache:region:collection'); $command = $this->application->find('orm:clear-cache:region:collection');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'owner-class' => State::class, 'owner-class' => State::class,
'association' => 'cities', 'association' => 'cities',
], ['decorated' => false] ],
['decorated' => false]
); );
$this->assertEquals('Clearing second-level cache for collection "Doctrine\Tests\Models\Cache\State#cities"' . PHP_EOL, $tester->getDisplay()); $this->assertEquals('Clearing second-level cache for collection "Doctrine\Tests\Models\Cache\State#cities"' . PHP_EOL, $tester->getDisplay());
@ -73,15 +72,17 @@ class ClearCacheCollectionRegionCommandTest extends OrmFunctionalTestCase
public function testClearCacheEntryName() public function testClearCacheEntryName()
{ {
$command = $this->application->find('orm:clear-cache:region:collection'); $command = $this->application->find('orm:clear-cache:region:collection');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'owner-class' => State::class, 'owner-class' => State::class,
'association' => 'cities', 'association' => 'cities',
'owner-id' => 1, 'owner-id' => 1,
], ['decorated' => false] ],
['decorated' => false]
); );
$this->assertEquals('Clearing second-level cache entry for collection "Doctrine\Tests\Models\Cache\State#cities" owner entity identified by "1"' . PHP_EOL, $tester->getDisplay()); $this->assertEquals('Clearing second-level cache entry for collection "Doctrine\Tests\Models\Cache\State#cities" owner entity identified by "1"' . PHP_EOL, $tester->getDisplay());
@ -89,15 +90,17 @@ class ClearCacheCollectionRegionCommandTest extends OrmFunctionalTestCase
public function testFlushRegionName() public function testFlushRegionName()
{ {
$command = $this->application->find('orm:clear-cache:region:collection'); $command = $this->application->find('orm:clear-cache:region:collection');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'owner-class' => State::class, 'owner-class' => State::class,
'association' => 'cities', 'association' => 'cities',
'--flush' => true, '--flush' => true,
], ['decorated' => false] ],
['decorated' => false]
); );
$this->assertEquals('Flushing cache provider configured for "Doctrine\Tests\Models\Cache\State#cities"' . PHP_EOL, $tester->getDisplay()); $this->assertEquals('Flushing cache provider configured for "Doctrine\Tests\Models\Cache\State#cities"' . PHP_EOL, $tester->getDisplay());

View File

@ -30,27 +30,24 @@ class ClearCacheEntityRegionCommandTest extends OrmFunctionalTestCase
$this->enableSecondLevelCache(); $this->enableSecondLevelCache();
parent::setUp(); parent::setUp();
$this->command = new EntityRegionCommand();
$this->application = new Application(); $this->application = new Application();
$this->command = new EntityRegionCommand(); $this->application->setHelperSet(new HelperSet(['em' => new EntityManagerHelper($this->_em)]));
$this->application->setHelperSet(new HelperSet(
[
'em' => new EntityManagerHelper($this->_em)
]
));
$this->application->add($this->command); $this->application->add($this->command);
} }
public function testClearAllRegion() public function testClearAllRegion()
{ {
$command = $this->application->find('orm:clear-cache:region:entity'); $command = $this->application->find('orm:clear-cache:region:entity');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'--all' => true, '--all' => true,
], ['decorated' => false] ],
['decorated' => false]
); );
$this->assertEquals('Clearing all second-level cache entity regions' . PHP_EOL, $tester->getDisplay()); $this->assertEquals('Clearing all second-level cache entity regions' . PHP_EOL, $tester->getDisplay());
@ -58,13 +55,15 @@ class ClearCacheEntityRegionCommandTest extends OrmFunctionalTestCase
public function testClearByEntityClassName() public function testClearByEntityClassName()
{ {
$command = $this->application->find('orm:clear-cache:region:entity'); $command = $this->application->find('orm:clear-cache:region:entity');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'entity-class' => Country::class, 'entity-class' => Country::class,
], ['decorated' => false] ],
['decorated' => false]
); );
$this->assertEquals('Clearing second-level cache for entity "Doctrine\Tests\Models\Cache\Country"' . PHP_EOL, $tester->getDisplay()); $this->assertEquals('Clearing second-level cache for entity "Doctrine\Tests\Models\Cache\Country"' . PHP_EOL, $tester->getDisplay());
@ -72,14 +71,16 @@ class ClearCacheEntityRegionCommandTest extends OrmFunctionalTestCase
public function testClearCacheEntryName() public function testClearCacheEntryName()
{ {
$command = $this->application->find('orm:clear-cache:region:entity'); $command = $this->application->find('orm:clear-cache:region:entity');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'entity-class' => Country::class, 'entity-class' => Country::class,
'entity-id' => 1, 'entity-id' => 1,
], ['decorated' => false] ],
['decorated' => false]
); );
$this->assertEquals('Clearing second-level cache entry for entity "Doctrine\Tests\Models\Cache\Country" identified by "1"' . PHP_EOL, $tester->getDisplay()); $this->assertEquals('Clearing second-level cache entry for entity "Doctrine\Tests\Models\Cache\Country" identified by "1"' . PHP_EOL, $tester->getDisplay());
@ -87,14 +88,16 @@ class ClearCacheEntityRegionCommandTest extends OrmFunctionalTestCase
public function testFlushRegionName() public function testFlushRegionName()
{ {
$command = $this->application->find('orm:clear-cache:region:entity'); $command = $this->application->find('orm:clear-cache:region:entity');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'entity-class' => Country::class, 'entity-class' => Country::class,
'--flush' => true, '--flush' => true,
], ['decorated' => false] ],
['decorated' => false]
); );
$this->assertEquals('Flushing cache provider configured for entity named "Doctrine\Tests\Models\Cache\Country"' . PHP_EOL, $tester->getDisplay()); $this->assertEquals('Flushing cache provider configured for entity named "Doctrine\Tests\Models\Cache\Country"' . PHP_EOL, $tester->getDisplay());

View File

@ -4,10 +4,10 @@ namespace Doctrine\Tests\ORM\Tools\Console\Command;
use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryRegionCommand; use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryRegionCommand;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Application;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Tester\CommandTester;
/** /**
* @group DDC-2183 * @group DDC-2183
@ -29,27 +29,24 @@ class ClearCacheQueryRegionCommandTest extends OrmFunctionalTestCase
$this->enableSecondLevelCache(); $this->enableSecondLevelCache();
parent::setUp(); parent::setUp();
$this->command = new QueryRegionCommand();
$this->application = new Application(); $this->application = new Application();
$this->command = new QueryRegionCommand(); $this->application->setHelperSet(new HelperSet(['em' => new EntityManagerHelper($this->_em)]));
$this->application->setHelperSet(new HelperSet(
[
'em' => new EntityManagerHelper($this->_em)
]
));
$this->application->add($this->command); $this->application->add($this->command);
} }
public function testClearAllRegion() public function testClearAllRegion()
{ {
$command = $this->application->find('orm:clear-cache:region:query'); $command = $this->application->find('orm:clear-cache:region:query');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'--all' => true, '--all' => true,
], ['decorated' => false] ],
['decorated' => false]
); );
$this->assertEquals('Clearing all second-level cache query regions' . PHP_EOL, $tester->getDisplay()); $this->assertEquals('Clearing all second-level cache query regions' . PHP_EOL, $tester->getDisplay());
@ -57,13 +54,15 @@ class ClearCacheQueryRegionCommandTest extends OrmFunctionalTestCase
public function testClearDefaultRegionName() public function testClearDefaultRegionName()
{ {
$command = $this->application->find('orm:clear-cache:region:query'); $command = $this->application->find('orm:clear-cache:region:query');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'region-name' => null, 'region-name' => null,
], ['decorated' => false] ],
['decorated' => false]
); );
$this->assertEquals('Clearing second-level cache query region named "query_cache_region"' . PHP_EOL, $tester->getDisplay()); $this->assertEquals('Clearing second-level cache query region named "query_cache_region"' . PHP_EOL, $tester->getDisplay());
@ -71,13 +70,15 @@ class ClearCacheQueryRegionCommandTest extends OrmFunctionalTestCase
public function testClearByRegionName() public function testClearByRegionName()
{ {
$command = $this->application->find('orm:clear-cache:region:query'); $command = $this->application->find('orm:clear-cache:region:query');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'region-name' => 'my_region', 'region-name' => 'my_region',
], ['decorated' => false] ],
['decorated' => false]
); );
$this->assertEquals('Clearing second-level cache query region named "my_region"' . PHP_EOL, $tester->getDisplay()); $this->assertEquals('Clearing second-level cache query region named "my_region"' . PHP_EOL, $tester->getDisplay());
@ -85,14 +86,16 @@ class ClearCacheQueryRegionCommandTest extends OrmFunctionalTestCase
public function testFlushRegionName() public function testFlushRegionName()
{ {
$command = $this->application->find('orm:clear-cache:region:query'); $command = $this->application->find('orm:clear-cache:region:query');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'region-name' => 'my_region', 'region-name' => 'my_region',
'--flush' => true, '--flush' => true,
], ['decorated' => false] ],
['decorated' => false]
); );
$this->assertEquals('Flushing cache provider configured for second-level cache query region named "my_region"' . PHP_EOL, $tester->getDisplay()); $this->assertEquals('Flushing cache provider configured for second-level cache query region named "my_region"' . PHP_EOL, $tester->getDisplay());

View File

@ -2,18 +2,18 @@
namespace Doctrine\Tests\ORM\Tools\Console\Command; namespace Doctrine\Tests\ORM\Tools\Console\Command;
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand; use Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Doctrine\Tests\Models\DDC3231\DDC3231EntityRepository; use Doctrine\Tests\Models\DDC3231\DDC3231EntityRepository;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Application;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Tester\CommandTester;
/**
* GenerateRepositoriesCommandTest
*/
class GenerateRepositoriesCommandTest extends OrmFunctionalTestCase class GenerateRepositoriesCommandTest extends OrmFunctionalTestCase
{ {
/** /**
@ -34,25 +34,12 @@ class GenerateRepositoriesCommandTest extends OrmFunctionalTestCase
\mkdir($this->path); \mkdir($this->path);
$metadataDriver = $this->_em->getConfiguration()->getMetadataDriverImpl(); $metadataDriver = $this->_em->getConfiguration()->getMetadataDriverImpl();
$metadataDriver->addPaths([__DIR__ . '/../../../../Models/DDC3231/']);
$metadataDriver->addPaths(
[
__DIR__ . '/../../../../Models/DDC3231/'
]
);
$this->application = new Application(); $this->application = new Application();
$this->application->setHelperSet(new HelperSet(['em' => new EntityManagerHelper($this->_em)]));
$this->application->setHelperSet(new HelperSet(
[
'em' => new EntityManagerHelper($this->_em)
]
));
$this->application->add(new GenerateRepositoriesCommand()); $this->application->add(new GenerateRepositoriesCommand());
} }
/** /**
@ -88,20 +75,20 @@ class GenerateRepositoriesCommandTest extends OrmFunctionalTestCase
$cname = 'Doctrine\Tests\Models\DDC3231\DDC3231User1Repository'; $cname = 'Doctrine\Tests\Models\DDC3231\DDC3231User1Repository';
$fname = str_replace('\\', DIRECTORY_SEPARATOR, $cname) . '.php'; $fname = str_replace('\\', DIRECTORY_SEPARATOR, $cname) . '.php';
$this->assertFileExists($this->path . DIRECTORY_SEPARATOR . $fname); self::assertFileExists($this->path . DIRECTORY_SEPARATOR . $fname);
$this->assertFileExists($this->path . DIRECTORY_SEPARATOR . 'DDC3231User1NoNamespaceRepository.php'); self::assertFileExists($this->path . DIRECTORY_SEPARATOR . 'DDC3231User1NoNamespaceRepository.php');
require $this->path . DIRECTORY_SEPARATOR . $fname; require $this->path . DIRECTORY_SEPARATOR . $fname;
require $this->path . DIRECTORY_SEPARATOR . 'DDC3231User1NoNamespaceRepository.php'; require $this->path . DIRECTORY_SEPARATOR . 'DDC3231User1NoNamespaceRepository.php';
$this->assertTrue(class_exists($cname)); self::assertTrue(class_exists($cname));
$this->assertTrue(class_exists('DDC3231User1NoNamespaceRepository')); self::assertTrue(class_exists('DDC3231User1NoNamespaceRepository'));
$repo1 = new \ReflectionClass($cname); $repo1 = new \ReflectionClass($cname);
$repo2 = new \ReflectionClass('DDC3231User1NoNamespaceRepository'); $repo2 = new \ReflectionClass('DDC3231User1NoNamespaceRepository');
$this->assertSame(EntityRepository::class, $repo1->getParentClass()->getName()); self::assertSame(EntityRepository::class, $repo1->getParentClass()->getName());
$this->assertSame(EntityRepository::class, $repo2->getParentClass()->getName()); self::assertSame(EntityRepository::class, $repo2->getParentClass()->getName());
} }
public function testGenerateRepositoriesCustomDefaultRepository() public function testGenerateRepositoriesCustomDefaultRepository()
@ -111,20 +98,20 @@ class GenerateRepositoriesCommandTest extends OrmFunctionalTestCase
$cname = 'Doctrine\Tests\Models\DDC3231\DDC3231User2Repository'; $cname = 'Doctrine\Tests\Models\DDC3231\DDC3231User2Repository';
$fname = str_replace('\\', DIRECTORY_SEPARATOR, $cname) . '.php'; $fname = str_replace('\\', DIRECTORY_SEPARATOR, $cname) . '.php';
$this->assertFileExists($this->path . DIRECTORY_SEPARATOR . $fname); self::assertFileExists($this->path . DIRECTORY_SEPARATOR . $fname);
$this->assertFileExists($this->path . DIRECTORY_SEPARATOR . 'DDC3231User2NoNamespaceRepository.php'); self::assertFileExists($this->path . DIRECTORY_SEPARATOR . 'DDC3231User2NoNamespaceRepository.php');
require $this->path . DIRECTORY_SEPARATOR . $fname; require $this->path . DIRECTORY_SEPARATOR . $fname;
require $this->path . DIRECTORY_SEPARATOR . 'DDC3231User2NoNamespaceRepository.php'; require $this->path . DIRECTORY_SEPARATOR . 'DDC3231User2NoNamespaceRepository.php';
$this->assertTrue(class_exists($cname)); self::assertTrue(class_exists($cname));
$this->assertTrue(class_exists('DDC3231User2NoNamespaceRepository')); self::assertTrue(class_exists('DDC3231User2NoNamespaceRepository'));
$repo1 = new \ReflectionClass($cname); $repo1 = new \ReflectionClass($cname);
$repo2 = new \ReflectionClass('DDC3231User2NoNamespaceRepository'); $repo2 = new \ReflectionClass('DDC3231User2NoNamespaceRepository');
$this->assertSame(DDC3231EntityRepository::class, $repo1->getParentClass()->getName()); self::assertSame(DDC3231EntityRepository::class, $repo1->getParentClass()->getName());
$this->assertSame(DDC3231EntityRepository::class, $repo2->getParentClass()->getName()); self::assertSame(DDC3231EntityRepository::class, $repo2->getParentClass()->getName());
} }
/** /**
@ -137,13 +124,14 @@ class GenerateRepositoriesCommandTest extends OrmFunctionalTestCase
$this->_em->getConfiguration()->setDefaultRepositoryClassName($defaultRepository); $this->_em->getConfiguration()->setDefaultRepositoryClassName($defaultRepository);
} }
$command = $this->application->find('orm:generate-repositories'); $command = $this->application->find('orm:generate-repositories');
$tester = new CommandTester($command); $tester = new CommandTester($command);
$tester->execute( $tester->execute(
[ [
'command' => $command->getName(), 'command' => $command->getName(),
'dest-path' => $this->path, 'dest-path' => $this->path,
'--filter' => $filter, '--filter' => $filter,
] ]
); );
} }

View File

@ -2,6 +2,10 @@
namespace Doctrine\Tests\ORM\Tools\Console\Command; namespace Doctrine\Tests\ORM\Tools\Console\Command;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Doctrine\Tests\Models\Cache\AttractionInfo; use Doctrine\Tests\Models\Cache\AttractionInfo;
use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\City;
@ -33,23 +37,19 @@ class InfoCommandTest extends OrmFunctionalTestCase
parent::setUp(); parent::setUp();
$this->application = new Application(); $this->application = new Application();
$command = new InfoCommand();
$this->application->setHelperSet( $this->application->setHelperSet(new HelperSet(['em' => new EntityManagerHelper($this->_em)]));
new HelperSet(['em' => new EntityManagerHelper($this->_em)]) $this->application->add(new InfoCommand());
);
$this->application->add($command); $this->command = $this->application->find('orm:info');
$this->tester = new CommandTester($this->command);
$this->command = $this->application->find('orm:info');
$this->tester = new CommandTester($command);
} }
public function testListAllClasses() public function testListAllClasses()
{ {
$this->tester->execute(['command' => $this->command->getName()]); $this->tester->execute(['command' => $this->command->getName()]);
$this->assertContains(AttractionInfo::class, $this->tester->getDisplay()); self::assertContains(AttractionInfo::class, $this->tester->getDisplay());
$this->assertContains(City::class, $this->tester->getDisplay()); self::assertContains(City::class, $this->tester->getDisplay());
} }
} }

View File

@ -37,32 +37,26 @@ class MappingDescribeCommandTest extends OrmFunctionalTestCase
parent::setUp(); parent::setUp();
$this->application = new Application(); $this->application = new Application();
$command = new MappingDescribeCommand(); $this->application->setHelperSet(new HelperSet(['em' => new EntityManagerHelper($this->_em)]));
$this->application->add(new MappingDescribeCommand());
$this->application->setHelperSet(new HelperSet(
[
'em' => new EntityManagerHelper($this->_em)
]
));
$this->application->add($command);
$this->command = $this->application->find('orm:mapping:describe'); $this->command = $this->application->find('orm:mapping:describe');
$this->tester = new CommandTester($command); $this->tester = new CommandTester($this->command);
} }
public function testShowSpecificFuzzySingle() public function testShowSpecificFuzzySingle()
{ {
$this->tester->execute( $this->tester->execute(
[ [
'command' => $this->command->getName(), 'command' => $this->command->getName(),
'entityName' => 'AttractionInfo', 'entityName' => 'AttractionInfo',
] ]
); );
$display = $this->tester->getDisplay(); $display = $this->tester->getDisplay();
$this->assertContains(AttractionInfo::class, $display);
$this->assertContains('Root entity name', $display); self::assertContains(AttractionInfo::class, $display);
self::assertContains('Root entity name', $display);
} }
/** /**
@ -73,8 +67,8 @@ class MappingDescribeCommandTest extends OrmFunctionalTestCase
{ {
$this->tester->execute( $this->tester->execute(
[ [
'command' => $this->command->getName(), 'command' => $this->command->getName(),
'entityName' => 'Attraction', 'entityName' => 'Attraction',
] ]
); );
} }
@ -87,8 +81,8 @@ class MappingDescribeCommandTest extends OrmFunctionalTestCase
{ {
$this->tester->execute( $this->tester->execute(
[ [
'command' => $this->command->getName(), 'command' => $this->command->getName(),
'entityName' => 'AttractionFooBar' 'entityName' => 'AttractionFooBar',
] ]
); );
} }

View File

@ -38,15 +38,10 @@ class RunDqlCommandTest extends OrmFunctionalTestCase
parent::setUp(); parent::setUp();
$this->command = new RunDqlCommand();
$this->application = new Application(); $this->application = new Application();
$this->command = new RunDqlCommand(); $this->application->setHelperSet(new HelperSet(['em' => new EntityManagerHelper($this->_em)]));
$this->application->setHelperSet(new HelperSet(
[
'em' => new EntityManagerHelper($this->_em)
]
));
$this->application->add($this->command); $this->application->add($this->command);
$this->tester = new CommandTester($this->command); $this->tester = new CommandTester($this->command);
@ -54,7 +49,7 @@ class RunDqlCommandTest extends OrmFunctionalTestCase
public function testCommandName() public function testCommandName()
{ {
$this->assertSame($this->command, $this->application->get('orm:run-dql')); self::assertSame($this->command, $this->application->get('orm:run-dql'));
} }
public function testWillRunQuery() public function testWillRunQuery()
@ -62,17 +57,17 @@ class RunDqlCommandTest extends OrmFunctionalTestCase
$this->_em->persist(new DateTimeModel()); $this->_em->persist(new DateTimeModel());
$this->_em->flush(); $this->_em->flush();
$this->assertSame( self::assertSame(
0, 0,
$this->tester->execute( $this->tester->execute(
[ [
'command' => $this->command->getName(), 'command' => $this->command->getName(),
'dql' => 'SELECT e FROM ' . DateTimeModel::class . ' e', 'dql' => 'SELECT e FROM ' . DateTimeModel::class . ' e',
] ]
) )
); );
$this->assertContains(DateTimeModel::class, $this->tester->getDisplay()); self::assertContains(DateTimeModel::class, $this->tester->getDisplay());
} }
public function testWillShowQuery() public function testWillShowQuery()
@ -80,17 +75,17 @@ class RunDqlCommandTest extends OrmFunctionalTestCase
$this->_em->persist(new DateTimeModel()); $this->_em->persist(new DateTimeModel());
$this->_em->flush(); $this->_em->flush();
$this->assertSame( self::assertSame(
0, 0,
$this->tester->execute( $this->tester->execute(
[ [
'command' => $this->command->getName(), 'command' => $this->command->getName(),
'dql' => 'SELECT e FROM ' . DateTimeModel::class . ' e', 'dql' => 'SELECT e FROM ' . DateTimeModel::class . ' e',
'--show-sql' => 'true' '--show-sql' => 'true',
] ]
) )
); );
$this->assertStringMatchesFormat('%Astring%sSELECT %a', $this->tester->getDisplay()); self::assertStringMatchesFormat('%Astring%sSELECT %a', $this->tester->getDisplay());
} }
} }