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:

Wenona
3 days 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
...
Davida
4 days 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
...
Hermila
12 days 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
Tamar
3 hours 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
13 days 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
15 days 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
16 days ago
I agree with Alecia. It's important to have the correct dependency injection for reading the xml configuration files.
upvoted 0 times
...
Alecia
22 days ago
I think the Architect should inject a 'reader' dependency for 'Magento\Framework\Config\Data' in di.xml.
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77