71 $this->objectManagerFactory = $this->createMock(\
Magento\Framework\
App\ObjectManagerFactory::class);
72 $this->objectManager = $this->createMock(\
Magento\Framework\ObjectManagerInterface::class);
73 $this->dirs = $this->createPartialMock(\
Magento\Framework\
App\
Filesystem\DirectoryList::class, [
'getPath']);
74 $this->maintenanceMode = $this->createPartialMock(\
Magento\Framework\
App\MaintenanceMode::class, [
'isOn']);
75 $this->remoteAddress = $this->createMock(\
Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::class);
78 $this->logger = $this->createMock(\Psr\
Log\LoggerInterface::class);
80 $this->deploymentConfig = $this->createMock(\
Magento\Framework\
App\DeploymentConfig::class);
83 [\Magento\Framework\App\Filesystem\DirectoryList::class,
$this->dirs],
86 [\Magento\Framework\Filesystem::class,
$filesystem],
91 $this->objectManager->expects($this->any())->method(
'get')
92 ->will(($this->returnValueMap($mapObjectManager)));
94 $this->configDir = $this->getMockForAbstractClass(\
Magento\Framework\
Filesystem\Directory\ReadInterface::class);
96 $filesystem->expects($this->any())->method(
'getDirectoryRead')
97 ->will(($this->returnValue($this->configDir)));
99 $this->application = $this->getMockForAbstractClass(\
Magento\Framework\AppInterface::class);
101 $this->objectManager->expects($this->any())->method(
'create')
102 ->will(($this->returnValue($this->application)));
104 $this->objectManagerFactory->expects($this->any())->method(
'create')
105 ->will(($this->returnValue($this->objectManager)));
107 $this->bootstrapMock = $this->getMockBuilder(\
Magento\Framework\
App\Bootstrap::class)
108 ->setMethods([
'assertMaintenance',
'assertInstalled',
'getIsExpected',
'isInstalled',
'terminate'])
109 ->setConstructorArgs([$this->objectManagerFactory,
'', [
'value1',
'value2']])
116 $this->assertInstanceOf(\
Magento\Framework\
App\ObjectManagerFactory::class,
$result);
119 public function testCreateFilesystemDirectoryList()
130 public function testCreateFilesystemDriverPool()
132 $driverClass = get_class($this->getMockForAbstractClass(\
Magento\Framework\
Filesystem\DriverInterface::class));
138 $this->assertInstanceOf($driverClass,
$result->getDriver(
'custom'));
143 $testParams = [
'testValue1',
'testValue2'];
144 $bootstrap = self::createBootstrap($testParams);
145 $this->assertSame($testParams,
$bootstrap->getParams());
154 private function createBootstrap($testParams = [
'value1',
'value2'])
156 return new Bootstrap($this->objectManagerFactory,
'', $testParams);
162 $testArgs = [
'arg1',
'arg2'];
163 $this->assertSame($this->application,
$bootstrap->createApplication(
'someApplicationType', $testArgs));
169 $this->assertSame($this->objectManager,
$bootstrap->getObjectManager());
182 if ($modeFromEnvironment) {
185 if ($modeFromDeployment) {
186 $this->deploymentConfig->method(
'get')->willReturn($modeFromDeployment);
188 $bootstrap = self::createBootstrap($testParams);
189 $this->assertEquals($isDeveloper,
$bootstrap->isDeveloperMode());
208 $responseMock = $this->getMockForAbstractClass(\
Magento\Framework\
App\ResponseInterface::class);
209 $this->bootstrapMock->expects($this->once())->method(
'assertMaintenance')->will($this->returnValue(
null));
210 $this->bootstrapMock->expects($this->once())->method(
'assertInstalled')->will($this->returnValue(
null));
211 $this->application->expects($this->once())->method(
'launch')->willReturn($responseMock);
212 $this->bootstrapMock->run($this->application);
217 $expectedException = new \Exception(
'');
218 $this->bootstrapMock->expects($this->once())->method(
'assertMaintenance')
219 ->will($this->throwException($expectedException));
220 $this->bootstrapMock->expects($this->once())->method(
'terminate')->with($expectedException);
221 $this->application->expects($this->once())->method(
'catchException')->willReturn(
false);
222 $this->bootstrapMock->run($this->application);
227 $expectedException = new \Exception(
'');
228 $this->bootstrapMock->expects($this->once())->method(
'assertMaintenance')->will($this->returnValue(
null));
229 $this->bootstrapMock->expects($this->once())->method(
'assertInstalled')
230 ->will($this->throwException($expectedException));
231 $this->bootstrapMock->expects($this->once())->method(
'terminate')->with($expectedException);
232 $this->application->expects($this->once())->method(
'catchException')->willReturn(
false);
233 $this->bootstrapMock->run($this->application);
238 $expectedMaintenanceException = new \Exception(
'');
239 $this->bootstrapMock->expects($this->once())->method(
'assertMaintenance')
240 ->will($this->throwException($expectedMaintenanceException));
241 $this->bootstrapMock->expects($this->never())->method(
'assertInstalled');
242 $this->bootstrapMock->expects($this->once())->method(
'terminate')->with($expectedMaintenanceException);
243 $this->application->expects($this->once())->method(
'catchException')->willReturn(
false);
244 $this->bootstrapMock->run($this->application);
256 $this->maintenanceMode->expects($this->once())->method(
'isOn')->willReturn($isOn);
257 $this->remoteAddress->expects($this->once())->method(
'getRemoteAddress')->willReturn(
false);
258 $this->application->expects($this->never())->method(
'launch');
259 $this->application->expects($this->once())->method(
'catchException')->willReturn(
true);
284 $this->deploymentConfig->expects($this->once())->method(
'isAvailable')->willReturn($isInstalled);
285 $this->application->expects($this->never())->method(
'launch');
286 $this->application->expects($this->once())->method(
'catchException')->willReturn(
true);
testIsDeveloperMode($modeFromEnvironment, $modeFromDeployment, $isDeveloper)
const INIT_PARAM_FILESYSTEM_DRIVERS
const INIT_PARAM_FILESYSTEM_DIR_PATHS
testRunWithMaintenanceErrors()
const PARAM_REQUIRE_MAINTENANCE
if(defined('TESTS_MAGENTO_INSTALLATION') &&TESTS_MAGENTO_INSTALLATION==='enabled') $bootstrap
static createFilesystemDirectoryList($rootDir, array $initParams)
assertMaintenanceDataProvider()
testAssertMaintenance($isOn, $isExpected)
static createFilesystemDriverPool(array $initParams)
assertInstalledDataProvider()
const PARAM_REQUIRE_IS_INSTALLED
testCreateObjectManagerFactory()
static createObjectManagerFactory($rootDir, array $initParams)
testRunWithInstallErrors()
testAssertInstalled($isInstalled, $isExpected)
testIsDeveloperModeDataProvider()