Skip to content

Commit

Permalink
Adapt factory test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed Apr 12, 2024
1 parent e0cb8ac commit cd93def
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Dto/DataObject.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* Pimcore
Expand Down
27 changes: 25 additions & 2 deletions tests/Unit/Service/Factory/QueryFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Pimcore\Bundle\StaticResolverBundle\Models\DataObject\ClassDefinitionResolverInterface;
use Pimcore\Bundle\StudioApiBundle\Exception\InvalidQueryTypeException;
use Pimcore\Bundle\StudioApiBundle\Factory\QueryFactory;
use Pimcore\Bundle\StudioApiBundle\Factory\QueryFactoryInterface;
use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\AssetQuery;
use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\AssetQueryProviderInterface;
use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\DataObjectQuery;
Expand All @@ -36,7 +37,7 @@ final class QueryFactoryTest extends Unit
*/
public function testInvalidQueryType(): void
{
$queryFactory = new QueryFactory($this->mockAssetAdapterInterface());
$queryFactory = $this->getQueryFactory();
$this->expectExceptionMessage('Unknown query type: invalid');
$queryFactory->create('invalid');
}
Expand All @@ -47,12 +48,34 @@ public function testInvalidQueryType(): void
*/
public function testAssetQueryType(): void
{
$queryFactory = new QueryFactory($this->mockAssetAdapterInterface());
$queryFactory = $this->getQueryFactory();
$query = $queryFactory->create('asset');

$this->assertInstanceOf(AssetQuery::class, $query);
}


/**
* @throws InvalidQueryTypeException
* @throws Exception
*/
public function testDataObjectQueryType(): void
{
$queryFactory = $this->getQueryFactory();
$query = $queryFactory->create('dataObject');

$this->assertInstanceOf(DataObjectQuery::class, $query);
}


private function getQueryFactory(): QueryFactoryInterface
{
return new QueryFactory(
$this->mockAssetAdapterInterface(),
$this->mockDataObjectAdapterInterface()
);
}

/**
* @throws Exception
*/
Expand Down

0 comments on commit cd93def

Please sign in to comment.