mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-22 14:36:10 +01:00
Daniel Siepmann
53ee309768
We switched to PHPDataSets already but didn't migrate all usages. This commit now migrates all usages left behind.
107 lines
3.2 KiB
PHP
107 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace Wrm\Events\Tests\Functional\Cleanup;
|
|
|
|
use Codappix\Typo3PhpDatasets\TestingFramework;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
|
use Wrm\Events\Command\RemoveAllCommand;
|
|
|
|
/**
|
|
* @testdox Cleanup RemoveAll
|
|
*/
|
|
class RemoveAllTest extends FunctionalTestCase
|
|
{
|
|
use TestingFramework;
|
|
|
|
protected $testExtensionsToLoad = [
|
|
'typo3conf/ext/events',
|
|
];
|
|
|
|
protected $pathsToProvideInTestInstance = [
|
|
'typo3conf/ext/events/Tests/Functional/Cleanup/Fixtures/RemoveAllTestFileadmin/' => 'fileadmin/',
|
|
];
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->setUpBackendUserFromFixture(1);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function removesAllData(): void
|
|
{
|
|
$this->importPHPDataSet(__DIR__ . '/Fixtures/RemoveAllTestDatabase.php');
|
|
|
|
$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.');
|
|
}
|
|
}
|