You are here

abstract class AbstractDescriptorTest in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/console/Tests/Descriptor/AbstractDescriptorTest.php \Symfony\Component\Console\Tests\Descriptor\AbstractDescriptorTest

Hierarchy

  • class \Symfony\Component\Console\Tests\Descriptor\AbstractDescriptorTest extends \Symfony\Component\Console\Tests\Descriptor\PHPUnit_Framework_TestCase

Expanded class hierarchy of AbstractDescriptorTest

File

vendor/symfony/console/Tests/Descriptor/AbstractDescriptorTest.php, line 21

Namespace

Symfony\Component\Console\Tests\Descriptor
View source
abstract class AbstractDescriptorTest extends \PHPUnit_Framework_TestCase {

  /** @dataProvider getDescribeInputArgumentTestData */
  public function testDescribeInputArgument(InputArgument $argument, $expectedDescription) {
    $this
      ->assertDescription($expectedDescription, $argument);
  }

  /** @dataProvider getDescribeInputOptionTestData */
  public function testDescribeInputOption(InputOption $option, $expectedDescription) {
    $this
      ->assertDescription($expectedDescription, $option);
  }

  /** @dataProvider getDescribeInputDefinitionTestData */
  public function testDescribeInputDefinition(InputDefinition $definition, $expectedDescription) {
    $this
      ->assertDescription($expectedDescription, $definition);
  }

  /** @dataProvider getDescribeCommandTestData */
  public function testDescribeCommand(Command $command, $expectedDescription) {
    $this
      ->assertDescription($expectedDescription, $command);
  }

  /** @dataProvider getDescribeApplicationTestData */
  public function testDescribeApplication(Application $application, $expectedDescription) {

    // Replaces the dynamic placeholders of the command help text with a static version.
    // The placeholder %command.full_name% includes the script path that is not predictable
    // and can not be tested against.
    foreach ($application
      ->all() as $command) {
      $command
        ->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command
        ->getHelp()));
    }
    $this
      ->assertDescription($expectedDescription, $application);
  }
  public function getDescribeInputArgumentTestData() {
    return $this
      ->getDescriptionTestData(ObjectsProvider::getInputArguments());
  }
  public function getDescribeInputOptionTestData() {
    return $this
      ->getDescriptionTestData(ObjectsProvider::getInputOptions());
  }
  public function getDescribeInputDefinitionTestData() {
    return $this
      ->getDescriptionTestData(ObjectsProvider::getInputDefinitions());
  }
  public function getDescribeCommandTestData() {
    return $this
      ->getDescriptionTestData(ObjectsProvider::getCommands());
  }
  public function getDescribeApplicationTestData() {
    return $this
      ->getDescriptionTestData(ObjectsProvider::getApplications());
  }
  protected abstract function getDescriptor();
  protected abstract function getFormat();
  private function getDescriptionTestData(array $objects) {
    $data = array();
    foreach ($objects as $name => $object) {
      $description = file_get_contents(sprintf('%s/../Fixtures/%s.%s', __DIR__, $name, $this
        ->getFormat()));
      $data[] = array(
        $object,
        $description,
      );
    }
    return $data;
  }
  protected function assertDescription($expectedDescription, $describedObject) {
    $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
    $this
      ->getDescriptor()
      ->describe($output, $describedObject, array(
      'raw_output' => true,
    ));
    $this
      ->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output
      ->fetch())));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractDescriptorTest::assertDescription protected function 1
AbstractDescriptorTest::getDescribeApplicationTestData public function
AbstractDescriptorTest::getDescribeCommandTestData public function
AbstractDescriptorTest::getDescribeInputArgumentTestData public function
AbstractDescriptorTest::getDescribeInputDefinitionTestData public function
AbstractDescriptorTest::getDescribeInputOptionTestData public function
AbstractDescriptorTest::getDescriptionTestData private function
AbstractDescriptorTest::getDescriptor abstract protected function 4
AbstractDescriptorTest::getFormat abstract protected function 4
AbstractDescriptorTest::testDescribeApplication public function @dataProvider getDescribeApplicationTestData
AbstractDescriptorTest::testDescribeCommand public function @dataProvider getDescribeCommandTestData
AbstractDescriptorTest::testDescribeInputArgument public function @dataProvider getDescribeInputArgumentTestData
AbstractDescriptorTest::testDescribeInputDefinition public function @dataProvider getDescribeInputDefinitionTestData
AbstractDescriptorTest::testDescribeInputOption public function @dataProvider getDescribeInputOptionTestData