-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Bundle\Rest\Functional\SearchView\Criterion; | ||
|
||
use Ibexa\Tests\Bundle\Rest\Functional\SearchView\SearchCriterionTestCase; | ||
|
||
/** | ||
* @covers \Ibexa\Rest\Server\Input\Parser\Criterion\ContentName | ||
*/ | ||
final class ContentNameTest extends SearchCriterionTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->createFolder('foo', '/api/ibexa/v2/content/locations/1/2'); | ||
$this->createFolder('foobar', '/api/ibexa/v2/content/locations/1/2'); | ||
} | ||
|
||
/** | ||
* @return iterable<array{ | ||
* string, | ||
* string, | ||
* int, | ||
* }> | ||
*/ | ||
public function getCriteriaPayloads(): iterable | ||
{ | ||
yield 'Return content items that contain "foo" in name' => [ | ||
'json', | ||
$this->buildJsonCriterionQuery('"ContentNameCriterion": "foo*"'), | ||
2, | ||
]; | ||
|
||
yield 'No content items found with article in name' => [ | ||
'json', | ||
$this->buildJsonCriterionQuery('"ContentNameCriterion": "*article*"'), | ||
0, | ||
]; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Integration\Rest\Input\Parser\Criterion; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; | ||
use Ibexa\Contracts\Rest\Input\ParsingDispatcher; | ||
use Ibexa\Contracts\Test\Core\IbexaKernelTestCase; | ||
use Ibexa\Rest\Input\Handler\Json; | ||
use Ibexa\Rest\Input\Handler\Xml; | ||
|
||
abstract class BaseCriterionParserTestCase extends IbexaKernelTestCase | ||
{ | ||
protected ParsingDispatcher $parsingDispatcher; | ||
|
||
private Xml $xml; | ||
|
||
private Json $json; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->parsingDispatcher = $this->getIbexaTestCore()->getServiceByClassName(ParsingDispatcher::class); | ||
$this->xml = $this->getIbexaTestCore()->getServiceByClassName(Xml::class); | ||
$this->json = $this->getIbexaTestCore()->getServiceByClassName(Json::class); | ||
} | ||
|
||
/** | ||
* @dataProvider provideXml | ||
*/ | ||
final public function testXmlConversion(string $xml, CriterionInterface $expectedCriterion): void | ||
{ | ||
$data = $this->xml->convert($xml); | ||
$result = $this->parsingDispatcher->parse( | ||
$data, | ||
'application/vnd.ibexa.api.internal.activity_log.criteria' | ||
); | ||
|
||
self::assertIsArray($result); | ||
self::assertContainsOnlyInstancesOf(CriterionInterface::class, $result); | ||
self::assertCount(1, $result); | ||
[ $criterion ] = $result; | ||
self::assertEquals($expectedCriterion, $criterion); | ||
} | ||
|
||
/** | ||
* @dataProvider provideJson | ||
*/ | ||
final public function testJsonConversion(string $json, CriterionInterface $expectedCriterion): void | ||
{ | ||
$data = $this->json->convert($json); | ||
$result = $this->parsingDispatcher->parse( | ||
$data, | ||
'application/vnd.ibexa.api.internal.activity_log.criterion' | ||
); | ||
|
||
self::assertInstanceOf(CriterionInterface::class, $result); | ||
self::assertEquals($expectedCriterion, $result); | ||
} | ||
|
||
/** | ||
* @return iterable<array{string, \Ibexa\Contracts\ActivityLog\Values\ActivityLog\Criterion\CriterionInterface}> | ||
*/ | ||
abstract public static function provideXml(): iterable; | ||
Check failure on line 68 in tests/integration/Input/Parser/Criterion/BaseCriterionParserTestCase.php GitHub Actions / Unit & integration tests (7.4)
Check failure on line 68 in tests/integration/Input/Parser/Criterion/BaseCriterionParserTestCase.php GitHub Actions / Unit & integration tests (8.0)
Check failure on line 68 in tests/integration/Input/Parser/Criterion/BaseCriterionParserTestCase.php GitHub Actions / Unit & integration tests (8.2)
|
||
|
||
/** | ||
* @return iterable<array{string, \Ibexa\Contracts\ActivityLog\Values\ActivityLog\Criterion\CriterionInterface}> | ||
*/ | ||
abstract public static function provideJson(): iterable; | ||
Check failure on line 73 in tests/integration/Input/Parser/Criterion/BaseCriterionParserTestCase.php GitHub Actions / Unit & integration tests (7.4)
Check failure on line 73 in tests/integration/Input/Parser/Criterion/BaseCriterionParserTestCase.php GitHub Actions / Unit & integration tests (8.0)
Check failure on line 73 in tests/integration/Input/Parser/Criterion/BaseCriterionParserTestCase.php GitHub Actions / Unit & integration tests (8.2)
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Integration\Rest\Input\Parser\Criterion; | ||
|
||
use Ibexa\Tests\Core\Persistence\Legacy\Filter\BaseCriterionVisitorQueryBuilderTestCase; | ||
|
||
final class ContentNameTest extends BaseCriterionVisitorQueryBuilderTestCase | ||
{ | ||
protected function getCriterionQueryBuilders(): iterable | ||
{ | ||
// TODO: Implement getCriterionQueryBuilders() method. | ||
Check failure on line 17 in tests/integration/Input/Parser/Criterion/ContentNameTest.php GitHub Actions / Unit & integration tests (7.4)
Check failure on line 17 in tests/integration/Input/Parser/Criterion/ContentNameTest.php GitHub Actions / Unit & integration tests (8.0)
Check failure on line 17 in tests/integration/Input/Parser/Criterion/ContentNameTest.php GitHub Actions / Unit & integration tests (8.2)
|
||
} | ||
|
||
public function getFilteringCriteriaQueryData(): iterable | ||
Check failure on line 20 in tests/integration/Input/Parser/Criterion/ContentNameTest.php GitHub Actions / Unit & integration tests (7.4)
Check failure on line 20 in tests/integration/Input/Parser/Criterion/ContentNameTest.php GitHub Actions / Unit & integration tests (8.0)
Check failure on line 20 in tests/integration/Input/Parser/Criterion/ContentNameTest.php GitHub Actions / Unit & integration tests (8.2)
|
||
{ | ||
// TODO: Implement getFilteringCriteriaQueryData() method. | ||
Check failure on line 22 in tests/integration/Input/Parser/Criterion/ContentNameTest.php GitHub Actions / Unit & integration tests (7.4)
Check failure on line 22 in tests/integration/Input/Parser/Criterion/ContentNameTest.php GitHub Actions / Unit & integration tests (8.0)
Check failure on line 22 in tests/integration/Input/Parser/Criterion/ContentNameTest.php GitHub Actions / Unit & integration tests (8.2)
|
||
} | ||
} |