forked from neos/neos-development-collection
/
ImportedAssetRepositoryTest.php
69 lines (56 loc) · 2.44 KB
/
ImportedAssetRepositoryTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Neos\Media\Tests\Functional\Domain\Repository;
/*
* This file is part of the Neos.Media package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use Neos\Flow\Persistence\Doctrine\PersistenceManager;
use Neos\Media\Domain\Model\ImportedAsset;
use Neos\Media\Domain\Repository\ImportedAssetRepository;
use Neos\Media\Tests\Functional\AbstractTest;
class ImportedAssetRepositoryTest extends AbstractTest
{
/**
* @var boolean
*/
protected static $testablePersistenceEnabled = true;
/**
* @var ImportedAssetRepository
*/
protected $importedAssetRepository;
/**
* @return void
*/
public function setUp(): void
{
parent::setUp();
if (!$this->persistenceManager instanceof PersistenceManager) {
$this->markTestSkipped('Doctrine persistence is not enabled');
}
$this->importedAssetRepository = $this->objectManager->get(ImportedAssetRepository::class);
}
/**
* @test
*/
public function findOneByAssetSourceIdentifierAndRemoteAssetIdentifier_selects_original_asset()
{
// To validate original is not found accidentally by implicit identifier sorting, this is fixated in the test (there's no foreign key constraint)
$originalAssetIdentifier = 'd0105b8a-6f2c-47e3-b4a3-c2b5912e59e2';
$assetVariant1Identifier = '7cfa67b6-c094-4391-85fd-82e0b8212e48';
$importedAsset1 = new ImportedAsset('test-source', 'remote-id', $assetVariant1Identifier, new \DateTimeImmutable(), $originalAssetIdentifier);
$importedAsset2 = new ImportedAsset('test-source', 'remote-id', $originalAssetIdentifier, new \DateTimeImmutable(), null);
$this->importedAssetRepository->add($importedAsset1);
$this->importedAssetRepository->add($importedAsset2);
$this->persistenceManager->persistAll();
$this->persistenceManager->clearState();
/** @var ImportedAsset $importedAssetResult */
$importedAssetResult = $this->importedAssetRepository->findOneByAssetSourceIdentifierAndRemoteAssetIdentifier('test-source', 'remote-id');
$this->assertInstanceOf(ImportedAsset::class, $importedAssetResult);
$this->assertEquals($originalAssetIdentifier, $importedAssetResult->getLocalAssetIdentifier());
}
}