Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

magento/magento2#28579:DependencyTest does not analyze GraphQL schema… #28747

Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
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
4 changes: 1 addition & 3 deletions app/code/Magento/SwatchesGraphQl/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"php": "~7.3.0||~7.4.0",
"magento/framework": "*",
"magento/module-swatches": "*",
"magento/module-catalog": "*"
},
"suggest": {
"magento/module-catalog": "*",
"magento/module-catalog-graph-ql": "*"
},
"license": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ protected function setUp(): void
$fileResolverMock = $this->getMockBuilder(
\Magento\Framework\Config\FileResolverInterface::class
)->disableOriginalConstructor()->getMock();
$filePath1 = __DIR__ . '/../_files/schemaA.graphqls';
$filePath2 = __DIR__ . '/../_files/schemaB.graphqls';
$fileList = [
file_get_contents(__DIR__ . '/../_files/schemaA.graphqls'),
file_get_contents(__DIR__ . '/../_files/schemaB.graphqls')
$filePath1 => file_get_contents($filePath1),
$filePath2 => file_get_contents($filePath2)
];
$fileResolverMock->expects($this->any())->method('get')->willReturn($fileList);
$graphQlReader = $this->objectManager->create(
Expand Down Expand Up @@ -219,31 +221,25 @@ function ($a, $b) {
}
//Checks to make sure that the given description exists in the expectedOutput array
$this->assertArrayHasKey(

array_search(
'Comment for empty PhysicalProductInterface',
array_column($expectedOutput, 'description')
),
$expectedOutput

array_search(
'Comment for empty PhysicalProductInterface',
array_column($expectedOutput, 'description')
),
$expectedOutput
);
$this->assertArrayHasKey(

array_search(
'Comment for empty Enum',
array_column($expectedOutput, 'description')
),
$expectedOutput

array_search(
'Comment for empty Enum',
array_column($expectedOutput, 'description')
),
$expectedOutput
);
$this->assertArrayHasKey(

array_search(
'Comment for SearchResultPageInfo',
array_column($expectedOutput, 'description')
),
$expectedOutput

array_search(
'Comment for SearchResultPageInfo',
array_column($expectedOutput, 'description')
),
$expectedOutput
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,24 @@ protected function setUp(): void
$fileResolverMock = $this->getMockBuilder(
\Magento\Framework\Config\FileResolverInterface::class
)->disableOriginalConstructor()->getMock();
$filePath1 = __DIR__ . '/_files/schemaC.graphqls';
$filePath2 = __DIR__ . '/_files/schemaD.graphqls';
$fileList = [
file_get_contents(__DIR__ . '/_files/schemaC.graphqls'),
file_get_contents(__DIR__ . '/_files/schemaD.graphqls')
$filePath1 => file_get_contents($filePath1),
$filePath2 => file_get_contents($filePath2)
];
$fileResolverMock->expects($this->any())->method('get')->willReturn($fileList);
$graphQlReader = $objectManager->create(
\Magento\Framework\GraphQlSchemaStitching\GraphQlReader::class,
['fileResolver' => $fileResolverMock]
);
$reader = $objectManager->create(
// phpstan:ignore
\Magento\Framework\GraphQlSchemaStitching\Reader::class,
['readers' => ['graphql_reader' => $graphQlReader]]
);
$data = $objectManager->create(
// phpstan:ignore
\Magento\Framework\GraphQl\Config\Data ::class,
['reader' => $reader]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

/**
* Class DeclarativeDependencyTest
* Test for undeclared dependencies in declarative schema
*/
class DeclarativeDependencyTest extends \PHPUnit\Framework\TestCase
{
Expand All @@ -25,7 +26,7 @@ class DeclarativeDependencyTest extends \PHPUnit\Framework\TestCase
/**
* Sets up data
*
* @throws \Exception
* @throws \Magento\TestFramework\Inspection\Exception
*/
protected function setUp(): void
{
Expand All @@ -37,11 +38,12 @@ protected function setUp(): void
'MAGETWO-43654: The build is running from vendor/magento. DependencyTest is skipped.'
);
}
$this->dependencyProvider = new DeclarativeSchemaDependencyProvider();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$this->dependencyProvider = $objectManager->create(DeclarativeSchemaDependencyProvider::class);
}

/**
* @throws \Exception
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function testUndeclaredDependencies()
{
Expand Down Expand Up @@ -131,14 +133,14 @@ private function getErrorMessage(string $id): string
*
* @param string $file
* @return mixed
* @throws \Exception
* @throws \Magento\TestFramework\Inspection\Exception
*/
private function readJsonFile(string $file, bool $asArray = false)
{
$decodedJson = json_decode(file_get_contents($file), $asArray);
if (null == $decodedJson) {
//phpcs:ignore Magento2.Exceptions.DirectThrow
throw new \Exception("Invalid Json: $file");
throw new \Magento\TestFramework\Inspection\Exception("Invalid Json: $file");
}

return $decodedJson;
Expand Down
Loading