Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Adobe Exam AD0-E722 Topic 4 Question 13 Discussion

Actual exam question for Adobe's AD0-E722 exam
Question #: 13
Topic #: 4
[All AD0-E722 Questions]

In a custom module, an Architect wants to define a new xml configuration file. The module should be able to read all the xml configuration files declared in the system, merge them together, and use their values in PHP class.

Which two steps should the Architect make to meet this requirement? (Choose two.)

Show Suggested Answer Hide Answer
Suggested Answer: C

To create an integration test that executes different logic in different store views, the Architect needs to do the following steps:

Create one test class that extends MagentoTestFrameworkTestCaseAbstractController or MagentoTestFrameworkTestCaseAbstractBackendController, depending on the type of controller being tested1.

Create one test method that uses the @magentoDataFixture annotation to specify the data fixture file that creates the product2.

Use the MagentoTestFrameworkStoreExecuteInStoreContext class to execute the fixture and the tested logic in different store views. This class has a method called executeInStoreContext, which takes two parameters: the store ID and a callable function.The callable function will be executed in the context of the given store ID, and then the original store ID will be restored3. For example:

PHPAI-generated code. Review and use carefully.More info on FAQ.

public function testSomeLogic()

{

// Get the product from the fixture

$product = $this->getProduct();

// Get the ExecuteInStoreContext instance from the object manager

$executeInStoreContext = $this->_objectManager->get(MagentoTestFrameworkStoreExecuteInStoreContext::class);

// Execute the fixture in store view 3

$executeInStoreContext->executeInStoreContext(3, function () use ($product) {

// Do some operations on the product in store view 3

});

// Execute the tested logic in store view 4

$result = $executeInStoreContext->executeInStoreContext(4, function () use ($product) {

// Call the tested logic on the product in store view 4

return $this->someLogic->execute($product);

});

// Assert that the result is true

$this->assertTrue($result);

}


Integration tests | Magento 2 Developer Documentation

Data fixtures | Magento 2 Developer Documentation

MagentoTestFrameworkStoreExecuteInStoreContext | Magento 2 Developer Documentation

Contribute your Thoughts:

Stacey
23 days ago
This is a tough one, but I reckon the answer is A and E. The way I see it, you need to be able to read and merge those custom XML files, and a custom Reader class is the way to do it. Anything else would just be a half-baked solution, and we all know how well those go down in the real world!
upvoted 0 times
...
Wenona
1 months ago
D doesn't seem like the right approach. Appending the custom XML file name in Magento\\Config\\Model\\Config\\Structure\\Reader won't solve the problem of reading and merging the custom XML files.
upvoted 0 times
Tyisha
10 days ago
That makes sense, we need to inject the reader dependency and create a custom Reader class for handling the XML files.
upvoted 0 times
...
Stephane
19 days ago
E) Make a Reader class that implements '\\Magento\\Framework\\Config\\Reader\\Filesystem'
upvoted 0 times
...
Evelynn
22 days ago
A) Inject a 'reader' dependency for 'Magento\\Framework\\Config\\Data' in di.xml
upvoted 0 times
...
...
Davida
1 months ago
C seems like a good approach, but I'm not sure if it's the complete solution. I think we also need to handle the reading and merging of the custom XML files, so A and E are probably the way to go.
upvoted 0 times
Paris
8 days ago
Yes, those two steps should allow the module to read and merge the custom XML files as needed.
upvoted 0 times
...
Leota
14 days ago
I agree, A and E seem like the right steps to take in order to meet the requirement.
upvoted 0 times
...
Francesco
1 months ago
E) Make a Reader class that implements '\\Magento\\Framework\\Config\\Reader\\Filesystem'
upvoted 0 times
...
Jose
1 months ago
A) Inject a 'reader' dependency for 'Magento\\Framework\\Config\\Data' in di.xml
upvoted 0 times
...
...
Hermila
2 months ago
Hmm, I'm not sure about B. Modifying the get() method of Magento\\Framework\\Config\\Data seems like a bad idea, and might break other functionality. I'd go with A and E.
upvoted 0 times
Sabra
20 days ago
Yeah, I think A and E would be the better choices. It's important to avoid breaking existing functionality.
upvoted 0 times
...
Tamar
1 months ago
I agree, modifying the get() method could cause issues. Injecting a 'reader' dependency and creating a Reader class seems like a safer approach.
upvoted 0 times
...
...
Launa
2 months ago
I think the answer is A and E. We need to inject a reader dependency for Magento\\Framework\\Config\\Data, and create a custom Reader class that implements Magento\\Framework\\Config\\Reader\\Filesystem to read the custom XML files.
upvoted 0 times
...
Jeannine
2 months ago
I believe creating a Data class that implements '\Magento\Framework\Config\Data' is also crucial for merging and using the values in PHP class.
upvoted 0 times
...
Chuck
2 months ago
I agree with Alecia. It's important to have the correct dependency injection for reading the xml configuration files.
upvoted 0 times
...
Alecia
2 months ago
I think the Architect should inject a 'reader' dependency for 'Magento\Framework\Config\Data' in di.xml.
upvoted 0 times
...

Save Cancel