Skip to content

Commit

Permalink
[Tests] Added functional tests coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ciastektk committed Dec 22, 2023
1 parent d859335 commit ae4b959
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/bundle/Functional/SearchView/Criterion/ContentNameTest.php
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

View workflow job for this annotation

GitHub Actions / Unit & integration tests (7.4)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\BaseCriterionParserTestCase::provideXml() has invalid return type Ibexa\Contracts\ActivityLog\Values\ActivityLog\Criterion\CriterionInterface.

Check failure on line 68 in tests/integration/Input/Parser/Criterion/BaseCriterionParserTestCase.php

View workflow job for this annotation

GitHub Actions / Unit & integration tests (8.0)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\BaseCriterionParserTestCase::provideXml() has invalid return type Ibexa\Contracts\ActivityLog\Values\ActivityLog\Criterion\CriterionInterface.

Check failure on line 68 in tests/integration/Input/Parser/Criterion/BaseCriterionParserTestCase.php

View workflow job for this annotation

GitHub Actions / Unit & integration tests (8.2)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\BaseCriterionParserTestCase::provideXml() has invalid return type Ibexa\Contracts\ActivityLog\Values\ActivityLog\Criterion\CriterionInterface.

/**
* @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

View workflow job for this annotation

GitHub Actions / Unit & integration tests (7.4)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\BaseCriterionParserTestCase::provideJson() has invalid return type Ibexa\Contracts\ActivityLog\Values\ActivityLog\Criterion\CriterionInterface.

Check failure on line 73 in tests/integration/Input/Parser/Criterion/BaseCriterionParserTestCase.php

View workflow job for this annotation

GitHub Actions / Unit & integration tests (8.0)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\BaseCriterionParserTestCase::provideJson() has invalid return type Ibexa\Contracts\ActivityLog\Values\ActivityLog\Criterion\CriterionInterface.

Check failure on line 73 in tests/integration/Input/Parser/Criterion/BaseCriterionParserTestCase.php

View workflow job for this annotation

GitHub Actions / Unit & integration tests (8.2)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\BaseCriterionParserTestCase::provideJson() has invalid return type Ibexa\Contracts\ActivityLog\Values\ActivityLog\Criterion\CriterionInterface.
}
24 changes: 24 additions & 0 deletions tests/integration/Input/Parser/Criterion/ContentNameTest.php
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

View workflow job for this annotation

GitHub Actions / Unit & integration tests (7.4)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\ContentNameTest::getCriterionQueryBuilders() should return iterable<Ibexa\Contracts\Core\Repository\Values\Filter\CriterionQueryBuilder> but return statement is missing.

Check failure on line 17 in tests/integration/Input/Parser/Criterion/ContentNameTest.php

View workflow job for this annotation

GitHub Actions / Unit & integration tests (8.0)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\ContentNameTest::getCriterionQueryBuilders() should return iterable<Ibexa\Contracts\Core\Repository\Values\Filter\CriterionQueryBuilder> but return statement is missing.

Check failure on line 17 in tests/integration/Input/Parser/Criterion/ContentNameTest.php

View workflow job for this annotation

GitHub Actions / Unit & integration tests (8.2)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\ContentNameTest::getCriterionQueryBuilders() should return iterable<Ibexa\Contracts\Core\Repository\Values\Filter\CriterionQueryBuilder> but return statement is missing.
}

public function getFilteringCriteriaQueryData(): iterable

Check failure on line 20 in tests/integration/Input/Parser/Criterion/ContentNameTest.php

View workflow job for this annotation

GitHub Actions / Unit & integration tests (7.4)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\ContentNameTest::getFilteringCriteriaQueryData() return type has no value type specified in iterable type iterable.

Check failure on line 20 in tests/integration/Input/Parser/Criterion/ContentNameTest.php

View workflow job for this annotation

GitHub Actions / Unit & integration tests (8.0)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\ContentNameTest::getFilteringCriteriaQueryData() return type has no value type specified in iterable type iterable.

Check failure on line 20 in tests/integration/Input/Parser/Criterion/ContentNameTest.php

View workflow job for this annotation

GitHub Actions / Unit & integration tests (8.2)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\ContentNameTest::getFilteringCriteriaQueryData() return type has no value type specified in iterable type iterable.
{
// TODO: Implement getFilteringCriteriaQueryData() method.

Check failure on line 22 in tests/integration/Input/Parser/Criterion/ContentNameTest.php

View workflow job for this annotation

GitHub Actions / Unit & integration tests (7.4)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\ContentNameTest::getFilteringCriteriaQueryData() should return iterable but return statement is missing.

Check failure on line 22 in tests/integration/Input/Parser/Criterion/ContentNameTest.php

View workflow job for this annotation

GitHub Actions / Unit & integration tests (8.0)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\ContentNameTest::getFilteringCriteriaQueryData() should return iterable but return statement is missing.

Check failure on line 22 in tests/integration/Input/Parser/Criterion/ContentNameTest.php

View workflow job for this annotation

GitHub Actions / Unit & integration tests (8.2)

Method Ibexa\Tests\Integration\Rest\Input\Parser\Criterion\ContentNameTest::getFilteringCriteriaQueryData() should return iterable but return statement is missing.
}
}

0 comments on commit ae4b959

Please sign in to comment.