importCSVDataSet(__DIR__ . '/Fixtures/Database/Pages.csv'); $this->subject = new CreateTestDataCommand(self::COMMAND_NAME); $application = new Application(); $application->add($this->subject); $command = $application->find('tea:create-test-data'); $this->commandTester = new CommandTester($command); } /** * @test */ public function isConsoleCommand(): void { self::assertInstanceOf(Command::class, $this->subject); } /** * @test */ public function hasDescription(): void { $expected = 'Create test data for the tea extension in an already existing page (sysfolder).'; self::assertSame($expected, $this->subject->getHelp()); } /** * @test */ public function hasHelpText(): void { $expected = 'Create test data for the tea extension in an already existing page (sysfolder).'; self::assertSame($expected, $this->subject->getHelp()); } /** * @test */ public function runReturnsSuccessStatus(): void { $result = $this->commandTester->execute( [ 'pageUid' => 1, ], ); self::assertSame(Command::SUCCESS, $result); } /** * @test */ public function createsTestData(): void { $this->commandTester->execute([ 'pageUid' => 1, ]); $this->assertCSVDataSet(__DIR__ . '/Fixtures/Database/Teas.csv'); } /** * @test */ public function deletesExistingDataOnGivenPidBeforeCreatingNewData(): void { $this->importCSVDataSet(__DIR__ . '/Fixtures/Database/ExistingTeas.csv'); $this->commandTester->execute( [ 'pageUid' => 1, '--delete-data-before' => true, ] ); $this->assertCSVDataSet(__DIR__ . '/Fixtures/Database/TeasAfterDelete.csv'); } /** * @test */ public function doesNotDeleteDataOnOtherPid(): void { $this->importCSVDataSet(__DIR__ . '/Fixtures/Database/OtherExistingTeas.csv'); $this->commandTester->execute( [ 'pageUid' => 1, '--delete-data-before' => true, ] ); $this->assertCSVDataSet(__DIR__ . '/Fixtures/Database/TeasAfterDeleteOtherExistingTeas.csv'); } }