예제 #1
0
 /**
  * @test
  */
 public function downloadExistingPage()
 {
     $this->wgetCommand->setOutputFile(Files::concatenatePaths(array($this->workingDirectory, 'wget.log')))->setDirectoryPrefix($this->workingDirectory)->setNoVerbose(true)->setServerResponse(true)->setUrl('http://localhost/')->execute();
     $log = $this->wgetLogParser->parseLog($this->wgetCommand);
     $this->assertFalse($log->hasErrors());
     $this->assertFileExists(Files::concatenatePaths(array($this->workingDirectory, 'index.html')));
 }
 /**
  * @test
  * @throws \Tx_PtExtbase_Exception_Internal
  */
 public function parseLogWithErrors()
 {
     $logOutPutFile = Files::concatenatePaths(array(__DIR__, 'TestData/WgetTest.log'));
     $wgetCommand = new \PunktDe\PtExtbase\Utility\Wget\WgetCommand();
     $wgetCommand->setNoVerbose(true)->setOutputFile($logOutPutFile);
     $logFileEntries = $this->wgetLogParser->parseLog($wgetCommand);
     $this->assertCount(4, $logFileEntries);
     // Case 200
     $logFileEntry1 = array('date' => date_create_from_format('Y-m-d H:i:s', '2015-02-26 11:50:40'), 'url' => 'https://test.de/data-ok.html', 'status' => 200, 'length' => 3951);
     $this->assertEquals($logFileEntry1, $logFileEntries->getItemByIndex(0)->toArray());
     // Case 404
     $logFileEntry2 = array('date' => date_create_from_format('Y-m-d H:i:s', '2015-02-26 11:50:57'), 'url' => 'https://test.de/typo3conf/jquery.selectBox-arrow.gif', 'status' => 404, 'length' => 275);
     $this->assertEquals($logFileEntry2, $logFileEntries->getItemByIndex(1)->toArray());
     // Case 200 after 404
     $logFileEntry3 = array('date' => date_create_from_format('Y-m-d H:i:s', '2015-02-26 11:50:40'), 'url' => 'https://test.de/data-ok2.html', 'status' => 200, 'length' => 1000);
     $this->assertEquals($logFileEntry3, $logFileEntries->getItemByIndex(2)->toArray());
     // Case 404 on last line
     $logFileEntry4 = array('date' => date_create_from_format('Y-m-d H:i:s', '2015-02-27 12:07:49'), 'url' => 'http://partnerportal.dpppa.dev.punkt.de/typo3conf/ext/pt_dppp_base/Resources/Public/Styles/jquery.selectBox-arrow.gif', 'status' => 404, 'length' => 275);
     $this->assertEquals($logFileEntry4, $logFileEntries->getItemByIndex(3)->toArray());
 }