45 private $serializerMock;
49 $context = $this->getMockBuilder(\
Magento\Framework\Model\Context::class)
50 ->disableOriginalConstructor()
52 $this->localeDate = $this->getMockBuilder(
53 \
Magento\Framework\Stdlib\DateTime\TimezoneInterface::class
55 $this->dateTime = $this->getMockBuilder(\
Magento\Framework\Stdlib\DateTime::class)
56 ->disableOriginalConstructor()
59 ->disableOriginalConstructor()
61 $this->cacheManager = $this->getMockBuilder(\
Magento\Framework\
App\CacheInterface::class)->getMock();
63 $context->expects($this->any())
64 ->method(
'getCacheManager')
65 ->willReturn($this->cacheManager);
67 $this->serializerMock = $this->createMock(SerializerInterface::class);
69 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
73 'context' => $context,
74 'localeDate' => $this->localeDate,
75 'dateTime' => $this->dateTime,
76 'resource' => $this->resource,
77 'serializer' => $this->serializerMock,
95 $localDate =
'2\28\2000';
97 $cacheId =
'design_change_' . md5(
$storeId . $date);
98 $this->localeDate->expects($this->once())
99 ->method(
'scopeTimeStamp')
101 ->willReturn($localDate);
102 $this->dateTime->expects($this->once())
103 ->method(
'formatDate')
104 ->with($localDate,
false)
106 $this->cacheManager->expects($this->once())
110 $this->resource->expects($this->once())
111 ->method(
'loadChange')
114 $this->serializerMock->expects($this->once())
115 ->method(
'serialize')
116 ->willReturn(
'serializedData');
117 $this->cacheManager->expects($this->once())
122 $this->assertInstanceOf(get_class($this->model), $this->model->loadChange(
$storeId));
135 $localDate =
'2\28\2000';
136 $date =
'28-02-2000';
137 $cacheId =
'design_change_' . md5(
$storeId . $date);
138 $this->localeDate->expects($this->once())
139 ->method(
'scopeTimeStamp')
141 ->willReturn($localDate);
142 $this->dateTime->expects($this->once())
143 ->method(
'formatDate')
144 ->with($localDate,
false)
146 $this->cacheManager->expects($this->once())
149 ->willReturn(
'serializedData');
150 $data = [
'test' =>
'data'];
151 $this->serializerMock->expects($this->once())
152 ->method(
'unserialize')
153 ->with(
'serializedData')
157 $this->assertInstanceOf(get_class($this->model),
$change);
171 $this->model->setId(
$id);
182 public function testChangeDesign()
184 $design = $this->getMockBuilder(\
Magento\Framework\View\DesignInterface::class)->getMock();
186 $this->model->setDesign(
'test');
188 $this->assertInstanceOf(get_class($this->model), $this->model->changeDesign($design));
testLoadChangeFromCache()