N98\Magento\Command\Category\Create\DummyCommandTest::testExecute PHP Method

testExecute() public method

public testExecute ( )
    public function testExecute()
    {
        $application = $this->getApplication();
        $application->add(new DummyCommand());
        $command = $application->find('category:create:dummy');
        $commandTester = new CommandTester($command);
        $commandTester->execute(array('command' => $command->getName(), 'store-id' => 1, 'children-categories-number' => 1, 'category-name-prefix' => 'My Awesome Category', 'category-number' => 1));
        $this->assertRegExp('/CATEGORY: \'My Awesome Category (.+)\' WITH ID: \'(.+)\' CREATED!/', $commandTester->getDisplay());
        $this->assertRegExp('/CATEGORY CHILD: \'My Awesome Category (.+)\' WITH ID: \'(.+)\' CREATED!/', $commandTester->getDisplay());
        // Check if the category is created correctly
        $match_parent = "";
        $match_child = "";
        preg_match('/CATEGORY: \'My Awesome Category (.+)\' WITH ID: \'(.+)\' CREATED!/', $commandTester->getDisplay(), $match_parent);
        $this->assertTrue($this->checkifCategoryExist($match_parent[2]));
        preg_match('/CATEGORY CHILD: \'My Awesome Category (.+)\' WITH ID: \'(.+)\' CREATED!/', $commandTester->getDisplay(), $match_child);
        $this->assertTrue($this->checkifCategoryExist($match_child[2]));
        // Delete category created
        $this->deleteMagentoCategory($match_parent[2]);
        $this->deleteMagentoCategory($match_child[2]);
    }