Added test
This commit is contained in:
parent
45ce6a41a3
commit
51cd8f7ce8
@ -32,6 +32,7 @@ use Symfony\Component\Console\Helper\TableHelper;
|
|||||||
* @link www.doctrine-project.org
|
* @link www.doctrine-project.org
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||||
|
* @author Daniel Leech <daniel@dantleech.com>
|
||||||
*/
|
*/
|
||||||
class InfoCommand extends Command
|
class InfoCommand extends Command
|
||||||
{
|
{
|
||||||
@ -62,6 +63,10 @@ or not.
|
|||||||
You can display the complete metadata for a given entity by specifying it, e.g.
|
You can display the complete metadata for a given entity by specifying it, e.g.
|
||||||
|
|
||||||
<info>%command.full_name%</info> My\Namespace\Entity\MyEntity
|
<info>%command.full_name%</info> My\Namespace\Entity\MyEntity
|
||||||
|
|
||||||
|
You can also specify a partial class name (as a regex):
|
||||||
|
|
||||||
|
<info>%command.full_name%</info> MyEntity
|
||||||
EOT
|
EOT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -253,7 +258,7 @@ EOT
|
|||||||
protected function formatListField($label, $values)
|
protected function formatListField($label, $values)
|
||||||
{
|
{
|
||||||
if (!$values) {
|
if (!$values) {
|
||||||
$out = '<comment>Empty</comment>';
|
$this->formatField($label, '<comment>Empty</comment>');
|
||||||
} else {
|
} else {
|
||||||
$this->formatField($label, array_shift($values));
|
$this->formatField($label, array_shift($values));
|
||||||
|
|
||||||
@ -261,8 +266,6 @@ EOT
|
|||||||
$this->formatField($label, $value);
|
$this->formatField($label, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->formatField($label, $out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function formatAssociationMappings($associationMappings)
|
protected function formatAssociationMappings($associationMappings)
|
||||||
|
@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Doctrine\Tests\ORM\Tools\Console\Command;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Tools\Console\Command\ClearCache\CollectionRegionCommand;
|
||||||
|
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\ORM\Tools\Console\Command\InfoCommand;
|
||||||
|
|
||||||
|
class InfoCommandTest extends OrmFunctionalTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Symfony\Component\Console\Application
|
||||||
|
*/
|
||||||
|
private $application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Doctrine\ORM\Tools\Console\Command\ClearCache\InfoCommand
|
||||||
|
*/
|
||||||
|
private $command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Symfony\Component\Console\Tester\CommandTester
|
||||||
|
*/
|
||||||
|
private $tester;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->application = new Application();
|
||||||
|
$command = new InfoCommand();
|
||||||
|
|
||||||
|
$this->application->setHelperSet(new HelperSet(array(
|
||||||
|
'em' => new EntityManagerHelper($this->_em)
|
||||||
|
)));
|
||||||
|
|
||||||
|
$this->application->add($command);
|
||||||
|
|
||||||
|
$this->command = $this->application->find('orm:info');
|
||||||
|
$this->tester = new CommandTester($command);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testListAllClasses()
|
||||||
|
{
|
||||||
|
$this->tester->execute(array(
|
||||||
|
'command' => $this->command->getName(),
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertContains('Doctrine\Tests\Models\Cache\AttractionInfo', $this->tester->getDisplay());
|
||||||
|
$this->assertContains('Doctrine\Tests\Models\Cache\City', $this->tester->getDisplay());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testShowSpecificFuzzySingle()
|
||||||
|
{
|
||||||
|
$this->tester->execute(array(
|
||||||
|
'command' => $this->command->getName(),
|
||||||
|
'entityName' => 'AttractionInfo',
|
||||||
|
));
|
||||||
|
|
||||||
|
$display = $this->tester->getDisplay();
|
||||||
|
$this->assertContains('Doctrine\Tests\Models\Cache\AttractionInfo', $display);
|
||||||
|
$this->assertContains('Root entity name', $display);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
* @expectedExceptionMessage possible matches: "Doctrine\Tests\Models\Cache\AttractionInfo
|
||||||
|
*/
|
||||||
|
public function testShowSpecificFuzzyAmbiguous()
|
||||||
|
{
|
||||||
|
$this->tester->execute(array(
|
||||||
|
'command' => $this->command->getName(),
|
||||||
|
'entityName' => 'Attraction',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
* @expectedExceptionMessage Could not find any mapped Entity classes matching "AttractionFooBar"
|
||||||
|
*/
|
||||||
|
public function testShowSpecificNotFound()
|
||||||
|
{
|
||||||
|
$this->tester->execute(array(
|
||||||
|
'command' => $this->command->getName(),
|
||||||
|
'entityName' => 'AttractionFooBar'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test takes a long time
|
||||||
|
*/
|
||||||
|
public function testShowSpecificSmokeTest()
|
||||||
|
{
|
||||||
|
$entityClassNames = $this->_em->getConfiguration()
|
||||||
|
->getMetadataDriverImpl()
|
||||||
|
->getAllClassNames();
|
||||||
|
|
||||||
|
foreach ($entityClassNames as $entityClassName) {
|
||||||
|
$this->tester->Execute(array(
|
||||||
|
'command' => $this->command->getName(),
|
||||||
|
'entityName' => $entityClassName
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user