/**
  * Check Doctrine connection
  *
  * @return Result
  */
 public function check()
 {
     $result = new Result($this->label);
     try {
         $this->db->connect();
     } catch (\Exception $e) {
         $result->setSuccess(false);
         $result->setError($e->getMessage());
     }
     return $result;
 }
 public function testFailer()
 {
     $mock = $this->getMockBuilder('BretRZaun\\StatusPage\\Check\\AbstractCheck')->setConstructorArgs(array('TestCheck'))->getMock();
     $result = new Result('TestCheck');
     $result->setSuccess(false);
     $result->setError('Failed');
     $mock->expects($this->once())->method('check')->willReturn($result);
     $this->app->register(new StatusPageServiceProvider(), array('statuspage.title' => 'TestPage', 'statuspage.checker' => $this->app->protect(function ($app, $statusChecker) use($mock) {
         $statusChecker->addCheck($mock);
     })));
     $client = $this->createClient();
     $crawler = $client->request('GET', '/status');
     $this->assertFalse($client->getResponse()->isOk());
     $this->assertEquals(503, $client->getResponse()->getStatusCode());
     $this->assertCount(1, $crawler->filter('th:contains("TestCheck")'));
     $this->assertCount(1, $crawler->filter('td:contains("Failed")'));
 }
 public function check()
 {
     $result = new Result($this->label);
     if (!file_exists($this->filename)) {
         $result->setSuccess(false);
         $result->setError("Log file {$this->filename} does not exist!");
         return $result;
     }
     if (!empty($this->content)) {
         $fileContent = file_get_contents($this->filename);
         if (strstr($fileContent, $this->content) === false) {
             $result->setSuccess(false);
             $result->setError('Log file failure');
             $result->setDetails('Timestamp: ' . date('d.m.Y H:i', filemtime($this->filename)));
         }
     }
     return $result;
 }