BLACK FRIDAY SALE – Unlock Up to 25% OFF on All Exam Prep! - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Adobe AD0-E722 Exam - Topic 4 Question 13 Discussion

Posted by Lettie on Apr 10, 2024 at 01:18 PM

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.)

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

Get Premium AD0-E722 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
36 comments · newest first
RE
Ressie 12 months ago
Surprised that E is an option, isn't that overkill for just reading XML?
RO
Rosendo 1 year ago
Wait, can you really just append the file name like that?
WI
Willis 1 year ago
Definitely A, but D sounds a bit off.
AL
Alex 1 year ago
I think B could work too, but not sure if it's the best approach.
MI
Mitsue 1 year ago
A and E seem like the right steps to me.
AL
Alfred 1 year ago
I'm leaning towards appending the custom XML file name in di.xml, but I need to double-check if that's the right approach.
TR
Tran 1 year ago
I feel like writing a plugin for \Magento\Framework\Config\Data::get() could be a good option, but I can't recall the details.
RA
Rashida 1 year ago
I remember practicing a question about merging XML files, and I think creating a Reader class might be involved.
JE
Jesusita 1 year ago
I think we need to inject a 'reader' dependency in di.xml, but I'm not entirely sure if that's the only step.
LU
Lura 1 year ago
Okay, I think I've got a strategy here. I'll focus on the key requirements - reading all the XML config files, merging them, and using the values in a PHP class. Options A and E seem like the right steps to take.
JA
Jacquline 1 year ago
Hmm, I'm a bit confused by the wording of the question. I'll need to re-read it a few times to make sure I understand exactly what's being asked.
MO
Mohammad 1 year ago
This looks like a tricky one. I'll need to carefully review the options and think through the steps required to meet the requirements.
IZ
Izetta 1 year ago
I'm feeling pretty confident about this one. The question is straightforward, and the steps to solve it are clear to me. I'll go with options B and C.
BE
Beula 1 year ago
Okay, let me think this through. The question specifically mentions that the storage account is configured to use the customer-managed keys, so that narrows it down to the storage-related services. I'll go with Azure Files and Blob storage as my answers.
KA
Karrie 1 year ago
I'm pretty confident I know the answer to this one. Trace flags are used for Apex, Visualforce, and Process Builder, right?
BE
Bettyann 1 year ago
Okay, this seems straightforward. I just need to count the number of Multimedia users in the sample data provided. I'll go through the options and see which one matches the correct number.
ST
Stacey 2 years 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!
CA
Cassie 1 year ago
↳ replying to Stacey
Yeah, A and E make the most sense. We can't afford a half-baked solution for this.
HE
Hermila 1 year ago
↳ replying to Stacey
I agree, A and E seem like the best options. We definitely need a way to read and merge those files.
DI
Diego 1 year ago
↳ replying to Stacey
I think A and E are the way to go. You need a custom Reader class to handle those XML files.
WE
Wenona 2 years 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.
TY
Tyisha 2 years ago
↳ replying to Wenona
That makes sense, we need to inject the reader dependency and create a custom Reader class for handling the XML files.
ST
Stephane 2 years ago
↳ replying to Wenona
E) Make a Reader class that implements '\\Magento\\Framework\\Config\\Reader\\Filesystem'
EV
Evelynn 2 years ago
↳ replying to Wenona
A) Inject a 'reader' dependency for 'Magento\\Framework\\Config\\Data' in di.xml
DA
Davida 2 years 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.
PA
Paris 2 years ago
↳ replying to Davida
Yes, those two steps should allow the module to read and merge the custom XML files as needed.
LE
Leota 2 years ago
↳ replying to Davida
I agree, A and E seem like the right steps to take in order to meet the requirement.
FR
Francesco 2 years ago
↳ replying to Davida
E) Make a Reader class that implements '\\Magento\\Framework\\Config\\Reader\\Filesystem'
JO
Jose 2 years ago
↳ replying to Davida
A) Inject a 'reader' dependency for 'Magento\\Framework\\Config\\Data' in di.xml
HE
Hermila 2 years 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.
SA
Sabra 2 years ago
↳ replying to Hermila
Yeah, I think A and E would be the better choices. It's important to avoid breaking existing functionality.
TA
Tamar 2 years ago
↳ replying to Hermila
I agree, modifying the get() method could cause issues. Injecting a 'reader' dependency and creating a Reader class seems like a safer approach.
LA
Launa 2 years 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.
JE
Jeannine 2 years 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.
CH
Chuck 2 years ago
I agree with Alecia. It's important to have the correct dependency injection for reading the xml configuration files.
AL
Alecia 2 years ago
I think the Architect should inject a 'reader' dependency for 'Magento\Framework\Config\Data' in di.xml.
0/2000 characters

Save Cancel