* * 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:----HQI/SmplvEqmZpvCKP2YYsyPAZw4Q9uz4JYIv9SiK0MYN0u3VsrvdnRtj9bjA2uyBDqk5i24/bpq+/zsQOukNNZ/fdmZzrj8G0KqIFHgyalBQSKUGcPTSxDksnwXSzwYJEQGzZbXago+5BxIrsE/DxWNcPLVjLJSST22QDzJEaLA12fyV+PodNDEgCabEijdhM5qaYviQsuue+qYcpBvYj+Gi9rRGEVWaGA56f4U+PzZMYhID/ZIJIXcPtHIwO3p88dWZUT/0UU5klRuZZ954IbR4b6aCcrWdoRAkNb/m3GyPKn8iqC3Ot0/tMrTvIUVcsQxTDdHJPhudxYTT4B+0J+btwEzS8P6ZDnr5oRbLCqvAoFDv10DPBukz5Zp4/rgiGOyIidj715e3DVdxssHcXMPESS0dbIp6KUWNdgi4FxFzVYu6u64qUn5TV4jCPzVLhPI/4wmlwdv13/5abwAKL8fQwo41+gAfpYdXLb1U5g99NEF7sArB3oQ72zGTPq+aLcVKrVRXp5Lg3vhA/gX4s1dzQ8hzQUcpsxQCeX+pzS1b/a8OqxdP4/rxnrQzxPDcvUQhFnyOryL7gi62R8zQZbwIfNrI2pbtKMOZCElej2sSadk0q/0MlD6SDNLI4Do0JUy85I9Yf2mjyXPgBKCrxADZKXcNGkJDkRBmpvTk0A=----ATTACHMENT:----OTc4OTc5ODMzNjA5NTI1MSA4MjkwMjk1NjYwMDY1NjgxIDM3NTU5NjUwMzczMDQ5NDQ=