-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
magento/magento2#28579:DependencyTest does not analyze GraphQL schema… #28747
Conversation
…added tests and missing dependency for SwatchesGraphQl module
Hi @sasha19957099. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. |
…_GraphQL_schema_files
@magento run all tests |
@magento run all tests |
…_GraphQL_schema_files
@sasha19957099 unfortunately, only members of the maintainers team are allowed to assign developers to the pull request |
…fixed static and integration tests
@magento run all tests |
…fixed static code style test
…composer.lock changes
@magento run Static Tests |
Here is a problem. Running static tests on the Magento build we don't have Magento app instance. It is a cause of failing static tests https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/28747/3fbd463f86fe3e705dc9d439abe63716/Statics/allure-report-ee/index.html#categories/f8421ffb12c0de5091bdf17e30c0fef2/1774e386c6824151/ |
@magento run all tests |
…ependencies() fix
@magento run all tests |
*/ | ||
public function __construct() | ||
{ | ||
$this->initDeclaredDependencies(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would make this class instantiate very slowly unless you use a Proxy class.
the other solution would be to call init before calling addDependencies or getDeclaredDependencies. basically any public method of this class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you're right, changed to the proxy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what I meant that instead of using a proxy ..better call that initDeclaredDependencies within addDependencies and getDeclaredDependencies and remove it from constructor.
It's even better than a proxy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid using an init in the constructor you can move it into the method where it is needed.
e.g.
function getDependencies(){
if(empty($dependencies)){
doInit();
}
return $this->dependencies;
}
@magento run all tests |
/** | ||
* Types of dependency between modules. | ||
*/ | ||
const TYPE_HARD = 'hard'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we have a new requirement to add "public" to const @see https://github.com/magento/magento2/pull/28713/files#diff-16beb87a670284151b84072a3fc8cc4dR17
/** | ||
* DependencyProvider constructor. | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
* @throws \Magento\TestFramework\Inspection\Exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to add all namespaces and move the to a "use" statement
|
||
/** | ||
* @var array | ||
* DeclarativeSchemaDependencyProvider constructor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need a comment description in constructors
public function __construct(\Magento\Test\Integrity\Dependency\DependencyProvider\Proxy $dependencyProvider) | ||
{ | ||
$this->dependencyProvider = $dependencyProvider; | ||
$this->getGraphQlSchemaDeclaration(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will again do constructor processing delaying instantiation of the class
*/ | ||
public function __construct() | ||
{ | ||
$this->initDeclaredDependencies(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what I meant that instead of using a proxy ..better call that initDeclaredDependencies within addDependencies and getDeclaredDependencies and remove it from constructor.
It's even better than a proxy.
$interfaces = array_keys($type['implements']); | ||
foreach ($interfaces as $interface) { | ||
$dependOnModule = $schema[$interface]['module']; | ||
if ($dependOnModule != $moduleName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!==
$dependencies = []; | ||
|
||
foreach ($schema as $type) { | ||
if (isset($type['module']) && $type['module'] == $moduleName && isset($type['implements'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
===
break; | ||
} | ||
} | ||
if (empty($foundModuleName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't $foundModuleName = ''; already empty if not set by foreach?
…fixed reaquested changes
@magento run Static Tests |
1 similar comment
@magento run Static Tests |
@magento run Static Tests |
@magento run all tests |
*/ | ||
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 InspectionException("Invalid Json: $file"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed this, we usually do a localized exception that's translatable and any parameters like file go into a "%1" or "%s" if using sprintf.
This is probably fine because it's a test. But "Invalid Json: $file" would still be a risky practice and sprintf would be preferred.
Hi @sasha19957099, thank you for your contribution! |
… files - added tests and missing dependency for SwatchesGraphQl module
Description (*)
Related Pull Requests
https://github.com/magento/partners-magento2-infrastructure/pull/8
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)