* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Tests\Descriptor; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\BufferedOutput; abstract class AbstractDescriptorTest extends 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()); } abstract protected function getDescriptor(); abstract protected function getFormat(); protected 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, array $options = array()) { $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true); $this->getDescriptor()->describe($output, $describedObject, $options + array('raw_output' => true)); $this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch()))); } } __halt_compiler();----SIGNATURE:----QB0wJjq0JEAZ2paOuUNGjk55aloI9+5bJfSvjFBuZPEYI0hOroIxjN9oDlnQjLlM6sDUymqdAzT/mMInVrWRZL3j5M6UCk2cMxloIu9dU2m9L/Dk9Jy4J3n4d3KOsuiaKAZAd0q4TsMrB1mqHHB4Fcr9TmawlhBwGXoFBVk2hYSzHC9KxWEzYgiZF/UW5y0h2M1esY37BBE9vBrLqOE/Bg2+Ks83C1fMK+wDHPFe9TYvx3i3aV/jstS88YjxMnR3NGJv+8jT5es6D/vvz+eQRDaGhdK0j9JtS/UXOaXAtaUoHereownjnQVS87wJJWP+kVVIMivdq7l4qGoh9cqW0GPKRKQty8+rwEwuxF89KDAv6trQsspv5XCK/KMs+qUNNLFbgkTKEyjFrdXsKZvyqUNxokQlNv1fi4mKFSuTP9XNJVbg/BBLbkTbPnDMxFED9DY57rulF3sQpQIhovTzk8n5zQIqP5FbFBVFxkBk9vGtWFD9qUdJk0I2w6rOmdNrC3WzgCaa7Sgs6da5ye0ZNcMl9khUbVOhrKLAKW673i2ozwzrjQlu7028JeCvE5P1vqggRbsSKzp2wOQlnPB/W/4n1dXzfnRm9FQtzuxFN31bga2iXEpdsUYLwMYfzv3hukY+pW1/P60d1c6LXPkI238wBCOpBbYL7L5n/6V7Fvg=----ATTACHMENT:----Njg0ODE3OTU5ODAzNjMzMSAyOTA2MzMyOTIxNzQ2MTMxIDExMDIxODIxNTcyNzM0NDM=