* @coversDefaultClass Mage\Command\AbstractCommand
 */
class AbstractCommandTest extends BaseTest
{
    /**
     * @var AbstractCommand|PHPUnit_Framework_MockObject_MockObject
     */
    private $abstractCommand;
    /**
     * @before
     */
    public function before()
    {
        $this->abstractCommand = $this->getMockForAbstractClass('Mage\Command\AbstractCommand');
    }
    /**
     * @covers ::setConfig
     */
    public function testSetConfig()
    {
        $configMock = $this->getMock('Mage\Config');
        $this->doTestSetter($this->abstractCommand, 'config', $configMock);
    }
    /**
     * @covers ::getConfig
     */
    public function testGetConfig()
    {
        $configMock = $this->getMock('Mage\Config');
        $this->doTestGetter($this->abstractCommand, 'config', $configMock);
    }
    public function infoMessageProvider()
    {
        return array(
            'happy_path' => array(
                'name' => 'Example command',
                'helpMessage' => 'This command does everything you want to',
                'examples' => array(
                    array(
                        'snippet' => 'mage example',
                        'description' => 'Default command'
                    ),
                    array(
                        'snippet' => 'mage example light',
                        'description' => 'Runs the command with lights'
                    )
                ),
                'syntax' => 'mage example [light]',
                'output' => "\n"
                    . "Command: Example command\n"
                    . "This command does everything you want to\n"
                    . "\n"
                    . "Syntax:\n"
                    . "    mage example [light]\n"
                    . "\n"
                    . "Usage examples:\n"
                    . "    * Default command:\n"
                    . "        mage example\n"
                    . "    * Runs the command with lights:\n"
                    . "        mage example light\n"
            ),
            'no_help_message' => array(
                'name' => 'Example command',
                'helpMessage' => '',
                'examples' => array(
                    array(
                        'snippet' => 'mage example',
                        'description' => 'Default command'
                    ),
                    array(
                        'snippet' => 'mage example light',
                        'description' => 'Runs the command with lights'
                    )
                ),
                'syntax' => 'mage example [light]',
                'output' => "\n"
                    . "Command: Example command\n"
                    . "Syntax:\n"
                    . "    mage example [light]\n"
                    . "\n"
                    . "Usage examples:\n"
                    . "    * Default command:\n"
                    . "        mage example\n"
                    . "    * Runs the command with lights:\n"
                    . "        mage example light\n"
            ),
            'no_examples' => array(
                'name' => 'Example command',
                'helpMessage' => 'This command does everything you want to',
                'examples' => array(),
                'syntax' => 'mage example [light]',
                'output' => "\n"
                    . "Command: Example command\n"
                    . "This command does everything you want to\n"
                    . "\n"
                    . "Syntax:\n"
                    . "    mage example [light]\n"
            ),
            "no_syntax" => array(
                'name' => 'Example command',
                'helpMessage' => 'This command does everything you want to',
                'examples' => array(
                    array(
                        'snippet' => 'mage example',
                        'description' => 'Default command'
                    ),
                    array(
                        'snippet' => 'mage example light',
                        'description' => 'Runs the command with lights'
                    )
                ),
                'syntax' => '',
                'output' => "\n"
                    . "Command: Example command\n"
                    . "This command does everything you want to\n"
                    . "\n"
                    . "Usage examples:\n"
                    . "    * Default command:\n"
                    . "        mage example\n"
                    . "    * Runs the command with lights:\n"
                    . "        mage example light\n"
            ),
            "stripping_colons" => array(
                'name' => 'Example command',
                'helpMessage' => 'This command does everything you want to',
                'examples' => array(
                    array(
                        'snippet' => 'mage example',
                        'description' => 'Default command : '
                    ),
                    array(
                        'snippet' => 'mage example light',
                        'description' => 'Runs the command with lights:  '
                    )
                ),
                'syntax' => 'mage example [light]',
                'output' => "\n"
                    . "Command: Example command\n"
                    . "This command does everything you want to\n"
                    . "\n"
                    . "Syntax:\n"
                    . "    mage example [light]\n"
                    . "\n"
                    . "Usage examples:\n"
                    . "    * Default command:\n"
                    . "        mage example\n"
                    . "    * Runs the command with lights:\n"
                    . "        mage example light\n"
            ),
            "only_help" => array(
                'name' => 'Example command',
                'helpMessage' => 'This command does everything you want to',
                'examples' => array(),
                'syntax' => '',
                'output' => "\n"
                    . "Command: Example command\n"
                    . "This command does everything you want to\n"
            ),
            "only_examples" => array(
                'name' => 'Example command',
                'helpMessage' => '',
                'examples' => array(
                    array(
                        'snippet' => 'mage example',
                        'description' => 'Default command'
                    ),
                    array(
                        'snippet' => 'mage example light',
                        'description' => 'Runs the command with lights'
                    )
                ),
                'syntax' => '',
                'output' => "\n"
                    . "Command: Example command\n"
                    . "Usage examples:\n"
                    . "    * Default command:\n"
                    . "        mage example\n"
                    . "    * Runs the command with lights:\n"
                    . "        mage example light\n"
            ),
            "only_syntax" => array(
                'name' => 'Example command',
                'helpMessage' => '',
                'examples' => array(),
                'syntax' => 'mage example [light]',
                'output' => "\n"
                    . "Command: Example command\n"
                    . "Syntax:\n"
                    . "    mage example [light]\n"
            ),
            "no_name" => array(
                'name' => '',
                'helpMessage' => 'This command does everything you want to',
                'examples' => array(
                    array(
                        'snippet' => 'mage example',
                        'description' => 'Default command'
                    ),
                    array(
                        'snippet' => 'mage example light',
                        'description' => 'Runs the command with lights'
                    )
                ),
                'syntax' => 'mage example [light]',
                'output' => "\n"
                    . "This command does everything you want to\n"
                    . "\n"
                    . "Syntax:\n"
                    . "    mage example [light]\n"
                    . "\n"
                    . "Usage examples:\n"
                    . "    * Default command:\n"
                    . "        mage example\n"
                    . "    * Runs the command with lights:\n"
                    . "        mage example light\n"
            ),
            "no_info_at_all" => array(
                'name' => '',
                'helpMessage' => '',
                'examples' => array(),
                'syntax' => '',
                'output' => "\n"
                    . "Sorry, there's no help for this command at the moment.\n"
            )
        );
    }
    /**
     * @covers ::getInfoMessage
     * @covers ::setHelpMessage
     * @covers ::addUsageExample
     * @covers ::setSyntaxMessage
     * @covers ::setName
     *
     * @dataProvider infoMessageProvider
     */
    public function testGetInfoMessage($name, $helpMessage, $examples, $syntax, $expectedMessage)
    {
        /** @var AbstractCommand $command */
        $command = $this->getMockForAbstractClass('Mage\Command\AbstractCommand');
        $command->setName($name);
        foreach ($examples as $example) {
            $command->addUsageExample($example['snippet'], $example['description']);
        }
        $command->setHelpMessage($helpMessage);
        $command->setSyntaxMessage($syntax);
        $actualMessage = $command->getInfoMessage();
        $this->assertEquals($expectedMessage, $actualMessage);
    }
}