forked from drupal-graphql/graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dataproducer): Populate context default values before resolving
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\graphql\Kernel\DataProducer; | ||
|
||
use Drupal\Tests\graphql\Kernel\GraphQLTestBase; | ||
|
||
/** | ||
* Context default value test. | ||
* | ||
* @group graphql | ||
*/ | ||
class DefaultValueTest extends GraphQLTestBase { | ||
|
||
|
||
/** | ||
* Test that the entity_load data producer has the correct default values. | ||
*/ | ||
public function testEntityLoadDefaultValue(): void { | ||
$manager = $this->container->get('plugin.manager.graphql.data_producer'); | ||
$plugin = $manager->createInstance('entity_load'); | ||
// Only type is required. | ||
$plugin->setContextValue('type', 'node'); | ||
$context_values = $plugin->getContextValuesWithDefaults(); | ||
$this->assertSame(TRUE, $context_values['access']); | ||
$this->assertSame('view', $context_values['access_operation']); | ||
} | ||
|
||
} |