Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TimeZoneProviderTest.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class TimeZoneProviderTest extends \PHPUnit\Framework\TestCase
13 {
14  public function testGet()
15  {
16  $timeZone = $this->createMock(\Magento\Framework\Stdlib\DateTime\Timezone::class);
17  $objectManager = $this->getMockForAbstractClass(
18  \Magento\Framework\ObjectManagerInterface::class,
19  [],
20  '',
21  false
22  );
23  $objectManager->expects($this->once())
24  ->method('create')
25  ->with(
26  \Magento\Framework\Stdlib\DateTime\Timezone::class,
28  )
29  ->willReturn($timeZone);
31  $objectManagerProvider = $this->createMock(\Magento\Setup\Model\ObjectManagerProvider::class);
32  $objectManagerProvider->expects($this->any())
33  ->method('get')
34  ->willReturn($objectManager);
35  $object = new TimeZoneProvider($objectManagerProvider);
36  $this->assertSame($timeZone, $object->get());
37  // Assert that the provider always returns the same object
38  $this->assertSame($timeZone, $object->get());
39  }
40 }
$objectManager
Definition: bootstrap.php:17