9 use Magento\Analytics\Api\Data\LinkInterfaceFactory;
23 private $objectManagerHelper;
28 private $linkInterfaceFactoryMock;
33 private $fileInfoManagerMock;
38 private $storeManagerInterfaceMock;
43 private $linkInterfaceMock;
48 private $fileInfoMock;
58 private $linkProvider;
65 $this->linkInterfaceFactoryMock = $this->getMockBuilder(LinkInterfaceFactory::class)
66 ->disableOriginalConstructor()
67 ->setMethods([
'create'])
69 $this->fileInfoManagerMock = $this->getMockBuilder(FileInfoManager::class)
70 ->disableOriginalConstructor()
72 $this->storeManagerInterfaceMock = $this->getMockBuilder(StoreManagerInterface::class)
73 ->getMockForAbstractClass();
74 $this->linkInterfaceMock = $this->getMockBuilder(LinkInterface::class)
75 ->getMockForAbstractClass();
76 $this->fileInfoMock = $this->getMockBuilder(FileInfo::class)
77 ->disableOriginalConstructor()
79 $this->storeMock = $this->getMockBuilder(Store::class)
80 ->disableOriginalConstructor()
82 $this->objectManagerHelper =
new ObjectManagerHelper($this);
83 $this->linkProvider = $this->objectManagerHelper->getObject(
86 'linkFactory' => $this->linkInterfaceFactoryMock,
87 'fileInfoManager' => $this->fileInfoManagerMock,
88 'storeManager' => $this->storeManagerInterfaceMock
95 $baseUrl =
'http://magento.local/pub/media/';
96 $fileInfoPath =
'analytics/data.tgz';
97 $fileInitializationVector =
'er312esq23eqq';
98 $this->fileInfoManagerMock->expects($this->once())
100 ->willReturn($this->fileInfoMock);
101 $this->linkInterfaceFactoryMock->expects($this->once())
105 'initializationVector' => base64_encode($fileInitializationVector),
106 'url' => $baseUrl . $fileInfoPath
109 ->willReturn($this->linkInterfaceMock);
110 $this->storeManagerInterfaceMock->expects($this->once())
111 ->method(
'getStore')->willReturn($this->storeMock);
112 $this->storeMock->expects($this->once())
113 ->method(
'getBaseUrl')
117 ->willReturn($baseUrl);
118 $this->fileInfoMock->expects($this->atLeastOnce())
120 ->willReturn($fileInfoPath);
121 $this->fileInfoMock->expects($this->atLeastOnce())
122 ->method(
'getInitializationVector')
123 ->willReturn($fileInitializationVector);
124 $this->assertEquals($this->linkInterfaceMock, $this->linkProvider->get());
137 $this->fileInfoManagerMock->expects($this->once())
139 ->willReturn($this->fileInfoMock);
140 $this->fileInfoMock->expects($this->once())
142 ->willReturn($fileInfoPath);
143 $this->fileInfoMock->expects($this->any())
144 ->method(
'getInitializationVector')
145 ->willReturn($fileInitializationVector);
146 $this->linkProvider->get();
155 [
null,
'initVector'],
testFileNotReady($fileInfoPath, $fileInitializationVector)
fileNotReadyDataProvider()