Skip to content

Commit

Permalink
refs #4903 added test for web archiving. Added screen to log writers …
Browse files Browse the repository at this point in the history
…hoping no test fails because of this
  • Loading branch information
tsteur committed Mar 27, 2014
1 parent 3bfbb7b commit 754cf8a
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
69 changes: 69 additions & 0 deletions tests/PHPUnit/Integration/ArchiveWebTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

use Piwik\Access;
use Piwik\Date;
use Piwik\Option;
use Piwik\Plugins\SitesManager\API;

/**
* Tests to call the archive.php script via web and check there is no error,
*/
class Test_Piwik_Integration_ArchiveWebTest extends IntegrationTestCase
{
public static $fixture = null; // initialized below class definition

public static function createAccessInstance()
{
Access::setSingletonInstance($access = new Test_Access_OverrideLogin());
\Piwik\Piwik::postEvent('Request.initAuthenticationObject');
}

public function testWebArchiving()
{
self::$fixture->setUp();
self::deleteArchiveTables();

$host = Fixture::getRootUrl();
$token = Fixture::getTokenAuth();

$urlTmp = Option::get('piwikUrl');
Option::set('piwikUrl', $host . 'tests/PHPUnit/proxy/index.php');

$output = file_get_contents($host . 'tests/PHPUnit/proxy/archive.php?token_auth=' . $token);

if (!empty($urlTmp)) {
Option::set('piwikUrl', $urlTmp);
} else {
Option::delete('piwikUrl');
}

$this->assertContains('Starting Piwik reports archiving...', $output);
$this->assertContains('Archived website id = 1', $output);
$this->assertContains('Done archiving!', $output);
$this->compareArchivePhpOutputAgainstExpected($output);
}

private function compareArchivePhpOutputAgainstExpected($output)
{
$fileName = 'test_ArchiveCronTest_archive_php_cron_output.txt';
list($pathProcessed, $pathExpected) = static::getProcessedAndExpectedDirs();

$expectedOutputFile = $pathExpected . $fileName;

try {
$this->assertTrue(is_readable($expectedOutputFile));
$this->assertEquals(file_get_contents($expectedOutputFile), $output);
} catch (Exception $ex) {
$this->comparisonFailures[] = $ex;
}
}
}

Test_Piwik_Integration_ArchiveWebTest::$fixture = new Test_Piwik_Fixture_ManySitesImportedLogs();
Test_Piwik_Integration_ArchiveWebTest::$fixture->addSegments = true;
2 changes: 1 addition & 1 deletion tests/PHPUnit/TestingEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static function addHooks()
});

$config->Plugins_Tracker = array('Plugins_Tracker' => $trackerPluginsToLoad);
$config->log['log_writers'] = array('file');
$config->log['log_writers'] = array('file', 'screen');

$manager->unloadPlugins();

Expand Down

0 comments on commit 754cf8a

Please sign in to comment.