Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SeparateAppsTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
14 
18 class SeparateAppsTest extends \PHPUnit\Framework\TestCase
19 {
23  private $objectManager;
24 
28  protected function setUp()
29  {
30  $this->objectManager = Bootstrap::getObjectManager();
31  }
32 
39  {
40  $newRelicWrapper = $this->getMockBuilder(NewRelicWrapper::class)
41  ->setMethods(['setAppName'])
42  ->getMock();
43 
44  $this->objectManager->configure([NewRelicWrapper::class => ['shared' => true]]);
45  $this->objectManager->addSharedInstance($newRelicWrapper, NewRelicWrapper::class);
46 
47  $newRelicWrapper->expects($this->once())
48  ->method('setAppName')
49  ->with($this->equalTo('beverly_hills;beverly_hills_90210'));
50 
51  $state = $this->objectManager->get(State::class);
52 
53  $state->setAreaCode('90210');
54  }
55 
62  {
63  $newRelicWrapper = $this->getMockBuilder(NewRelicWrapper::class)
64  ->setMethods(['setAppName'])
65  ->getMock();
66 
67  $this->objectManager->configure([NewRelicWrapper::class => ['shared' => true]]);
68  $this->objectManager->addSharedInstance($newRelicWrapper, NewRelicWrapper::class);
69 
70  $newRelicWrapper->expects($this->never())->method('setAppName');
71 
72  $state = $this->objectManager->get(State::class);
73 
74  $state->setAreaCode('90210');
75  }
76 }