New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Adobe AD0-E722 Exam - Topic 1 Question 5 Discussion

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

An Architect wants to create an Integration Test that does the following:

* Adds a product using a data fixture

* Executes $this->someLogic->execute($product) on the product

* Checks if the result is true.

$this->someLogic has the correct object assigned in the setup() method.

Product creation and the tested logic must be executed in the context of two different store views with IDs of 3 and 4, which have been created and are available for the test.

How should the Architect meet these requirements?

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:

0/2000 characters
Francine
3 months ago
Totally agree with B, it's straightforward and clean!
upvoted 0 times
...
Vilma
3 months ago
Wait, can you really use the same context in one method?
upvoted 0 times
...
Ceola
3 months ago
C sounds a bit confusing, not sure it meets all requirements.
upvoted 0 times
...
Kris
4 months ago
I think A is better for clarity with separate classes.
upvoted 0 times
...
Bernardo
4 months ago
Option B seems like the most efficient way to handle this.
upvoted 0 times
...
Golda
4 months ago
I vaguely remember something about using the ExecuteInStoreContext class, but I thought it was more common to use it in separate methods rather than just once.
upvoted 0 times
...
Shawna
4 months ago
I feel like option B might be the right approach since it allows for clearer separation of the test methods, but I’m not completely confident.
upvoted 0 times
...
Eleni
4 months ago
I remember practicing a question where we had to use annotations for different store contexts, but I can't recall if it was one class or two.
upvoted 0 times
...
Maurine
5 months ago
I think option A sounds familiar, but I'm not entirely sure if we need separate classes for each store view.
upvoted 0 times
...
Roxane
5 months ago
I'm feeling pretty confident about this one. The key is to use the appropriate Magento testing framework classes and annotations to set up the store view context. I'll create a single test class with one method, and use the \Magento\TestFramework\Store\ExecuteInStoreContext class to handle the store view switching in the test.
upvoted 0 times
...
Noah
5 months ago
This seems a bit tricky with the multiple store view requirement. I'm thinking I might need to create two separate test classes, one for each store view, and use the @magentoExecuteInStoreContext annotation at the class level. That way, I can keep the test logic separate and ensure it runs in the correct context.
upvoted 0 times
...
Yaeko
5 months ago
Okay, I've got a plan. I'll create a single test class with two test methods, and use the @magentoStoreContext annotation to specify the store view ID in each method. That should cover the requirement to test in both store views.
upvoted 0 times
...
Myra
5 months ago
Hmm, I'm a bit unsure about the different store view IDs and how to properly set up the test context. I'll need to review the Magento testing framework documentation to make sure I understand the right approach here.
upvoted 0 times
...
Trinidad
5 months ago
This looks like a straightforward integration test setup. I think I can handle this - the key is to use the appropriate annotations to execute the test logic in the correct store view context.
upvoted 0 times
...
Louisa
5 months ago
I've got this! Case and Account are definitely going to be on the list. And since this is a support use case, Contract is a good choice too. I'm feeling confident about this one.
upvoted 0 times
...
Hyman
5 months ago
Based on the information provided, I believe the core file will be stored in the non-global zone's directory, as specified in the core dump configuration image.
upvoted 0 times
...
Arlette
5 months ago
Hmm, I'm not totally sure about this one. I'm thinking it could also be related to service discoverability, since hiding those implementation details could make it easier for consumers to find and use the service. But I'm not 100% confident.
upvoted 0 times
...
Bettyann
5 months ago
I might be mixing up some concepts, but I feel like there's definitely a range in how much miners can influence timestamps.
upvoted 0 times
...

Save Cancel