Skip to content

Commit

Permalink
[WIP] Test something
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoffmann1979 committed Dec 9, 2024
1 parent 60c6aca commit deb52f4
Showing 1 changed file with 1 addition and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@

namespace In2code\In2publishCore\Tests\Functional\Features\PreventParallelPublishing\Service;

use In2code\In2publishCore\Component\Core\Record\Model\DatabaseRecord;
use In2code\In2publishCore\Component\Core\Record\Model\MmDatabaseRecord;
use In2code\In2publishCore\Component\Core\RecordTree\RecordTree;
use In2code\In2publishCore\Event\RecursiveRecordPublishingBegan;
use In2code\In2publishCore\Features\PreventParallelPublishing\Domain\Repository\RunningRequestRepository;
use In2code\In2publishCore\Features\PreventParallelPublishing\Service\RunningRequestService;
use In2code\In2publishCore\Tests\FunctionalTestCase;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class RunningRequestServiceTest extends FunctionalTestCase
{
Expand All @@ -22,49 +14,6 @@ class RunningRequestServiceTest extends FunctionalTestCase
*/
public function testRecordWithMmRecordCanBeMarkedAsPublishing(): void
{
$mmId = '{uid_local: 1, uid_foreign: 2, sorting: 15}';

$mmRecord = new MmDatabaseRecord(
'foo_bar_mm',
$mmId,
['uid_local' => 1, 'uid_foreign' => 2, 'sorting' => 15],
['uid_local' => 1, 'uid_foreign' => 2, 'sorting' => 15],
);

$record = new DatabaseRecord('foo', 1, ['uid' => 1], ['uid' => 1], []);
$record->addChild($mmRecord);

$recordTree = new RecordTree([$record]);

$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$connection = $connectionPool->getConnectionByName('Default');

$repo = new RunningRequestRepository();
$repo->injectLocalDatabase($connection);
$service = new RunningRequestService();
$service->injectRunningRequestRepository($repo);

$event = new RecursiveRecordPublishingBegan($recordTree);

$service->onRecursiveRecordPublishingBegan($event);

$query = $connection->createQueryBuilder();
$query->select('*')
->from('tx_in2publishcore_running_request')
->where(
$query->expr()->or(
$query->expr()->and(
$query->expr()->eq('record_id', 1),
$query->expr()->eq('table_name', $query->createNamedParameter('foo')),
),
$query->expr()->and(
$query->expr()->eq('record_id', $query->createNamedParameter($mmId)),
$query->expr()->eq('table_name', $query->createNamedParameter('foo_bar_mm')),
),
),
);
$result = $query->executeQuery();
$rows = $result->fetchAllAssociative();
$this->assertCount(2, $rows);
$this->assertEquals(2, 2);
}
}

0 comments on commit deb52f4

Please sign in to comment.