2022-01-27 14:14:02 +01:00
|
|
|
<?php
|
|
|
|
|
2023-11-09 10:27:43 +01:00
|
|
|
namespace WerkraumMedia\Events\Tests\Unit\Domain\Model;
|
2022-01-27 14:14:02 +01:00
|
|
|
|
2023-06-07 08:56:42 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2022-01-27 14:14:02 +01:00
|
|
|
use TYPO3\CMS\Core\Resource\Folder;
|
2023-11-09 10:27:43 +01:00
|
|
|
use WerkraumMedia\Events\Domain\Model\Category;
|
|
|
|
use WerkraumMedia\Events\Domain\Model\Import;
|
|
|
|
use WerkraumMedia\Events\Domain\Model\Region;
|
|
|
|
use WerkraumMedia\Events\Tests\ProphecyTrait;
|
2022-01-27 14:14:02 +01:00
|
|
|
|
|
|
|
/**
|
2023-11-09 10:27:43 +01:00
|
|
|
* @covers \WerkraumMedia\Events\Domain\Model\Import
|
2022-01-27 14:14:02 +01:00
|
|
|
*/
|
|
|
|
class ImportTest extends TestCase
|
|
|
|
{
|
|
|
|
use ProphecyTrait;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function canBeCreated(): void
|
|
|
|
{
|
|
|
|
$folder = $this->prophesize(Folder::class);
|
|
|
|
|
|
|
|
$subject = new Import(
|
|
|
|
$folder->reveal(),
|
|
|
|
0,
|
|
|
|
''
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertInstanceOf(
|
|
|
|
Import::class,
|
|
|
|
$subject
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function returnsRestExperience(): void
|
|
|
|
{
|
|
|
|
$folder = $this->prophesize(Folder::class);
|
|
|
|
|
|
|
|
$subject = new Import(
|
|
|
|
$folder->reveal(),
|
|
|
|
0,
|
|
|
|
'experience'
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
'experience',
|
|
|
|
$subject->getRestExperience()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function returnsStoragePid(): void
|
|
|
|
{
|
|
|
|
$folder = $this->prophesize(Folder::class);
|
|
|
|
|
|
|
|
$subject = new Import(
|
|
|
|
$folder->reveal(),
|
|
|
|
20,
|
|
|
|
''
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
20,
|
|
|
|
$subject->getStoragePid()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function returnsRegion(): void
|
|
|
|
{
|
|
|
|
$folder = $this->prophesize(Folder::class);
|
|
|
|
$region = $this->prophesize(Region::class);
|
|
|
|
|
|
|
|
$subject = new Import(
|
|
|
|
$folder->reveal(),
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
null,
|
2022-07-05 14:08:14 +02:00
|
|
|
0,
|
|
|
|
null,
|
2022-01-27 14:14:02 +01:00
|
|
|
$region->reveal()
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
$region->reveal(),
|
|
|
|
$subject->getRegion()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function returnsFilesFolder(): void
|
|
|
|
{
|
|
|
|
$folder = $this->prophesize(Folder::class);
|
|
|
|
|
|
|
|
$subject = new Import(
|
|
|
|
$folder->reveal(),
|
|
|
|
0,
|
|
|
|
''
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
$folder->reveal(),
|
|
|
|
$subject->getFilesFolder()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function returnsCategoriesPid(): void
|
|
|
|
{
|
|
|
|
$folder = $this->prophesize(Folder::class);
|
|
|
|
|
|
|
|
$subject = new Import(
|
|
|
|
$folder->reveal(),
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
10
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
10,
|
|
|
|
$subject->getCategoriesPid()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function returnsCategoryParent(): void
|
|
|
|
{
|
|
|
|
$category = $this->prophesize(Category::class);
|
|
|
|
$folder = $this->prophesize(Folder::class);
|
|
|
|
|
|
|
|
$subject = new Import(
|
|
|
|
$folder->reveal(),
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
$category->reveal()
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
$category->reveal(),
|
|
|
|
$subject->getCategoryParent()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-07-05 14:08:14 +02:00
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function returnsFeaturesPid(): void
|
|
|
|
{
|
|
|
|
$folder = $this->prophesize(Folder::class);
|
|
|
|
|
|
|
|
$subject = new Import(
|
|
|
|
$folder->reveal(),
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
null,
|
|
|
|
10
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
10,
|
|
|
|
$subject->getFeaturesPid()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function returnsFeaturesParent(): void
|
|
|
|
{
|
|
|
|
$feature = $this->prophesize(Category::class);
|
|
|
|
$folder = $this->prophesize(Folder::class);
|
|
|
|
|
|
|
|
$subject = new Import(
|
|
|
|
$folder->reveal(),
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
null,
|
|
|
|
0,
|
|
|
|
$feature->reveal()
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
$feature->reveal(),
|
|
|
|
$subject->getFeaturesParent()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-27 14:14:02 +01:00
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function returnsSearchQuery(): void
|
|
|
|
{
|
|
|
|
$folder = $this->prophesize(Folder::class);
|
|
|
|
|
|
|
|
$subject = new Import(
|
|
|
|
$folder->reveal(),
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
'name:"Test"'
|
|
|
|
);
|
|
|
|
|
|
|
|
self::assertSame(
|
|
|
|
'name:"Test"',
|
|
|
|
$subject->getSearchQuery()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|