Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CustomerDataTest.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class CustomerDataTest extends \PHPUnit\Framework\TestCase
13 {
17  private $contextMock;
18 
22  private $scopeConfigMock;
23 
24  protected function setUp()
25  {
26  $this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)->getMock();
27  $this->contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
28  $this->contextMock->expects($this->once())->method('getScopeConfig')->willReturn($this->scopeConfigMock);
29  }
30 
32  {
33  $block = new CustomerData(
34  $this->contextMock,
35  [],
36  []
37  );
38 
39  $this->scopeConfigMock->expects($this->once())
40  ->method('getValue')
41  ->with('customer/online_customers/section_data_lifetime', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)
42  ->willReturn('10');
43 
44  $actualResult = $block->getExpirableSectionLifetime();
45  $this->assertSame(10, $actualResult);
46  }
47 
48  public function testGetExpirableSectionNames()
49  {
50  $expectedResult = ['cart'];
51  $block = new CustomerData(
52  $this->contextMock,
53  [],
54  $expectedResult
55  );
56 
57  $this->assertEquals($expectedResult, $block->getExpirableSectionNames());
58  }
59 }
$block
Definition: block.php:8