2021-12-16 14:07:32 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Wrm\Events\Tests\Functional\Cleanup;
|
|
|
|
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
|
use Wrm\Events\Command\RemoveAllCommand;
|
2023-05-16 09:46:53 +02:00
|
|
|
use Wrm\Events\Tests\Functional\AbstractFunctionalTestCase;
|
2021-12-16 14:07:32 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @testdox Cleanup RemoveAll
|
|
|
|
*/
|
2023-05-16 09:46:53 +02:00
|
|
|
class RemoveAllTest extends AbstractFunctionalTestCase
|
2021-12-16 14:07:32 +01:00
|
|
|
{
|
|
|
|
protected function setUp(): void
|
|
|
|
{
|
2023-06-19 10:13:26 +02:00
|
|
|
$this->pathsToProvideInTestInstance = [
|
|
|
|
'typo3conf/ext/events/Tests/Functional/Cleanup/Fixtures/RemoveAllTestFileadmin/' => 'fileadmin/',
|
|
|
|
];
|
2021-12-16 14:07:32 +01:00
|
|
|
|
2023-06-19 10:13:26 +02:00
|
|
|
parent::setUp();
|
2021-12-16 14:07:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function removesAllData(): void
|
|
|
|
{
|
2023-05-15 11:58:19 +02:00
|
|
|
$this->importPHPDataSet(__DIR__ . '/Fixtures/RemoveAllTestDatabase.php');
|
2021-12-16 14:07:32 +01:00
|
|
|
|
|
|
|
$subject = $this->getContainer()->get(RemoveAllCommand::class);
|
|
|
|
self::assertInstanceOf(Command::class, $subject);
|
|
|
|
|
|
|
|
$tester = new CommandTester($subject);
|
|
|
|
$tester->execute([], ['capture_stderr_separately' => true]);
|
|
|
|
|
|
|
|
self::assertSame(0, $tester->getStatusCode());
|
|
|
|
self::assertCount(
|
|
|
|
1,
|
|
|
|
$this->getAllRecords('tx_events_domain_model_partner'),
|
|
|
|
'Partners are not kept.'
|
|
|
|
);
|
|
|
|
self::assertCount(
|
|
|
|
1,
|
|
|
|
$this->getAllRecords('tx_events_domain_model_region'),
|
|
|
|
'Regions are not kept.'
|
|
|
|
);
|
|
|
|
self::assertCount(
|
|
|
|
1,
|
|
|
|
$this->getAllRecords('tx_events_domain_model_partner'),
|
|
|
|
'Partners are not kept.'
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertCount(
|
|
|
|
0,
|
|
|
|
$this->getAllRecords('tx_events_domain_model_organizer'),
|
|
|
|
'Organizers are still there.'
|
|
|
|
);
|
|
|
|
self::assertCount(
|
|
|
|
0,
|
|
|
|
$this->getAllRecords('tx_events_domain_model_event'),
|
|
|
|
'Events are still there.'
|
|
|
|
);
|
|
|
|
self::assertCount(
|
|
|
|
0,
|
|
|
|
$this->getAllRecords('tx_events_domain_model_date'),
|
|
|
|
'Dates are still there.'
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertCount(
|
|
|
|
0,
|
|
|
|
$this->getAllRecords('sys_category_record_mm'),
|
|
|
|
'Relations to categories still exist.'
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertCount(
|
|
|
|
1,
|
|
|
|
$this->getAllRecords('sys_file'),
|
|
|
|
'Unexpected number of sys_file records.'
|
|
|
|
);
|
|
|
|
self::assertCount(
|
|
|
|
1,
|
|
|
|
$this->getAllRecords('sys_file_reference'),
|
|
|
|
'Unexpected number of sys_file_reference records.'
|
|
|
|
);
|
|
|
|
self::assertCount(
|
|
|
|
1,
|
|
|
|
$this->getAllRecords('sys_file_metadata'),
|
|
|
|
'Unexpected number of sys_file_metadata records.'
|
|
|
|
);
|
|
|
|
|
|
|
|
$files = GeneralUtility::getFilesInDir('fileadmin/user_uploads');
|
|
|
|
self::assertIsArray($files, 'Failed to retrieve files from filesystem.');
|
|
|
|
self::assertCount(1, $files, 'Unexpectd number of files in filesystem.');
|
|
|
|
self::assertSame('example-for-partner.gif', array_values($files)[0], 'Unexpectd file in filesystem.');
|
|
|
|
}
|
|
|
|
}
|