Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
/features export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/phpunit_mongodb.xml export-ignore
/tests export-ignore
/update-js.sh export-ignore
/yarn.lock export-ignore
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ jobs:
run: vendor/bin/behat --out=std --format=progress --profile=default --no-interaction

mongodb:
name: Behat (PHP ${{ matrix.php }}) (MongoDB)
name: PHPUnit + Behat (PHP ${{ matrix.php }}) (MongoDB)
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
Expand Down Expand Up @@ -528,8 +528,8 @@ jobs:
run: vendor/bin/simple-phpunit --version
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run PHPUnit
run: vendor/bin/simple-phpunit
- name: Run PHPUnit tests
run: vendor/bin/simple-phpunit --group mongodb
- name: Run Behat tests
run: vendor/bin/behat -vv --out=std --format=progress --profile=mongodb --no-interaction

Expand Down Expand Up @@ -584,8 +584,6 @@ jobs:
run: vendor/bin/simple-phpunit --version
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run PHPUnit tests
run: vendor/bin/simple-phpunit
- name: Run Behat tests
run: vendor/bin/behat --out=std --format=progress --profile=elasticsearch --no-interaction

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* OpenAPI: Fix error when schema is empty (#4051)
* OpenAPI: Do not set scheme to oauth2 when generating securitySchemes (#4073)
* OpenAPI: Fix missing `$ref` when no `type` is used in context (#4076)
* GraphQL: Fix "Resource class cannot be determined." error when a null iterable field is returned (#4092)

## 2.6.2

Expand Down
17 changes: 17 additions & 0 deletions features/graphql/query.feature
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ Feature: GraphQL query support
And the JSON node "data.dummy.jsonData.bar" should be equal to 5
And the JSON node "data.dummy.arrayData[2]" should be equal to baz

Scenario: Retrieve an item with an iterable null field
Given there are 2 dummy with null JSON objects
When I send the following GraphQL request:
"""
{
withJsonDummy(id: "/with_json_dummies/2") {
id
json
}
}
"""
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json"
And the JSON node "data.withJsonDummy.id" should be equal to "/with_json_dummies/2"
And the JSON node "data.withJsonDummy.json" should be null

Scenario: Retrieve an item through a GraphQL query with variables
When I have the following GraphQL request:
"""
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<server name="SYMFONY_PHPUNIT_REMOVE" value="symfony/yaml" />
<server name="KERNEL_DIR" value="tests/Fixtures/app/" />
<server name="KERNEL_CLASS" value="AppKernel" />
<server name="APP_ENV" value="test" />
<env name="APP_ENV" value="test" />
</php>

<testsuites>
Expand Down
41 changes: 0 additions & 41 deletions phpunit_mongodb.xml

This file was deleted.

2 changes: 1 addition & 1 deletion src/GraphQl/Resolver/Factory/ItemResolverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __invoke(?string $resourceClass = null, ?string $rootClass = nul
{
return function (?array $source, array $args, $context, ResolveInfo $info) use ($resourceClass, $rootClass, $operationName) {
// Data already fetched and normalized (field or nested resource)
if (isset($source[$info->fieldName])) {
if ($source && \array_key_exists($info->fieldName, $source)) {
return $source[$info->fieldName];
}

Expand Down
25 changes: 25 additions & 0 deletions tests/Behat/DoctrineContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\ThirdLevel as ThirdLevelDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\UrlEncodedId as UrlEncodedIdDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\User as UserDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\WithJsonDummy as WithJsonDummyDocument;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\AbsoluteUrlDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\AbsoluteUrlRelationDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Address;
Expand Down Expand Up @@ -155,6 +156,7 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\UrlEncodedId;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\User;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\UuidIdentifierDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\WithJsonDummy;
use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\PyStringNode;
use Doctrine\ODM\MongoDB\DocumentManager;
Expand Down Expand Up @@ -574,6 +576,21 @@ public function thereAreDummyObjectsWithJsonData(int $nb)
$this->manager->flush();
}

/**
* @Given there are :nb dummy with null JSON objects
*/
public function thereAreDummyWithNullJsonObjects(int $nb)
{
for ($i = 1; $i <= $nb; ++$i) {
$dummy = $this->buildWithJsonDummy();
$dummy->json = null;

$this->manager->persist($dummy);
}

$this->manager->flush();
}

/**
* @Given there are :nb dummy objects with relatedDummy and its thirdLevel
* @Given there is :nb dummy object with relatedDummy and its thirdLevel
Expand Down Expand Up @@ -2199,4 +2216,12 @@ private function buildCustomMultipleIdentifierDummy()
{
return $this->isOrm() ? new CustomMultipleIdentifierDummy() : new CustomMultipleIdentifierDummyDocument();
}

/**
* @return WithJsonDummy|WithJsonDummyDocument
*/
private function buildWithJsonDummy()
{
return $this->isOrm() ? new WithJsonDummy() : new WithJsonDummyDocument();
}
}
120 changes: 120 additions & 0 deletions tests/Bridge/Doctrine/MongoDbOdm/Filter/SearchFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,36 @@ public function provideApplyTestData(): array
],
$filterFactory,
],
'partial (multiple values)' => [
[
[
'$match' => [
'name' => [
'$in' => [
new Regex('CaSE'),
new Regex('SENSitive'),
],
],
],
],
],
$filterFactory,
],
'partial (multiple values; case insensitive)' => [
[
[
'$match' => [
'name' => [
'$in' => [
new Regex('CaSE', 'i'),
new Regex('inSENSitive', 'i'),
],
],
],
],
],
$filterFactory,
],
'start' => [
[
[
Expand Down Expand Up @@ -423,6 +453,36 @@ public function provideApplyTestData(): array
],
$filterFactory,
],
'start (multiple values)' => [
[
[
'$match' => [
'name' => [
'$in' => [
new Regex('^CaSE'),
new Regex('^SENSitive'),
],
],
],
],
],
$filterFactory,
],
'start (multiple values; case insensitive)' => [
[
[
'$match' => [
'name' => [
'$in' => [
new Regex('^CaSE', 'i'),
new Regex('^inSENSitive', 'i'),
],
],
],
],
],
$filterFactory,
],
'end' => [
[
[
Expand Down Expand Up @@ -451,6 +511,36 @@ public function provideApplyTestData(): array
],
$filterFactory,
],
'end (multiple values)' => [
[
[
'$match' => [
'name' => [
'$in' => [
new Regex('CaSE$'),
new Regex('SENSitive$'),
],
],
],
],
],
$filterFactory,
],
'end (multiple values; case insensitive)' => [
[
[
'$match' => [
'name' => [
'$in' => [
new Regex('CaSE$', 'i'),
new Regex('inSENSitive$', 'i'),
],
],
],
],
],
$filterFactory,
],
'word_start' => [
[
[
Expand Down Expand Up @@ -479,6 +569,36 @@ public function provideApplyTestData(): array
],
$filterFactory,
],
'word_start (multiple values)' => [
[
[
'$match' => [
'name' => [
'$in' => [
new Regex('(^CaSE.*|.*\sCaSE.*)'),
new Regex('(^SENSitive.*|.*\sSENSitive.*)'),
],
],
],
],
],
$filterFactory,
],
'word_start (multiple values; case insensitive)' => [
[
[
'$match' => [
'name' => [
'$in' => [
new Regex('(^CaSE.*|.*\sCaSE.*)', 'i'),
new Regex('(^inSENSitive.*|.*\sinSENSitive.*)', 'i'),
],
],
],
],
],
$filterFactory,
],
'invalid value for relation' => [
[],
$filterFactory,
Expand Down
Loading