+ self::assertFalse($this->root->hasChild('config/local.config.php'));
+
+ $mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
+
+ self::assertTrue($mode->isInstall());
+ self::assertFalse($mode->isNormal());
+
+ self::assertFalse($mode->has(Mode::LOCALCONFIGPRESENT));
+ }
+
+ public function testWithoutDatabase()
+ {
+ $this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
+
+ $this->databaseMock->shouldReceive('connected')->andReturn(false)->once();
+
+ $mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
+
+ self::assertFalse($mode->isNormal());
+ self::assertTrue($mode->isInstall());
+
+ self::assertTrue($mode->has(Mode::LOCALCONFIGPRESENT));
+ self::assertFalse($mode->has(Mode::DBAVAILABLE));
+ }
+
+ public function testWithoutDatabaseSetup()
+ {
+ $this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
+
+ $this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
+ $this->databaseMock->shouldReceive('fetchFirst')
+ ->with('SHOW TABLES LIKE \'config\'')->andReturn(false)->once();
+
+ $mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
+
+ self::assertFalse($mode->isNormal());
+ self::assertTrue($mode->isInstall());
+
+ self::assertTrue($mode->has(Mode::LOCALCONFIGPRESENT));
+ }
+
+ public function testWithMaintenanceMode()
+ {
+ $this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
+
+ $this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
+ $this->databaseMock->shouldReceive('fetchFirst')
+ ->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
+ $this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
+ ->andReturn(true)->once();
+
+ $mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
+
+ self::assertFalse($mode->isNormal());
+ self::assertFalse($mode->isInstall());
+
+ self::assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
+ self::assertFalse($mode->has(Mode::MAINTENANCEDISABLED));
+ }
+
+ public function testNormalMode()
+ {
+ $this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
+
+ $this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
+ $this->databaseMock->shouldReceive('fetchFirst')
+ ->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
+ $this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
+ ->andReturn(false)->once();
+ $this->databaseMock->shouldReceive('selectFirst')
+ ->with('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])
+ ->andReturn(['v' => null])->once();