Skip to content

Commit

Permalink
Refs #4087, remove recursive links and create/remove them only when d…
Browse files Browse the repository at this point in the history
…oing UI tests.
  • Loading branch information
Benaka Moorthi committed Aug 30, 2013
1 parent 0bafc83 commit 01e5881
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
39 changes: 32 additions & 7 deletions tests/PHPUnit/UITest.php
Expand Up @@ -16,6 +16,8 @@ abstract class UITest extends IntegrationTestCase
const IMAGE_TYPE = 'png';
const CAPTURE_PROGRAM = 'phantomjs';

private static $recursiveProxyLinkNames = array('libs', 'plugins', 'tests');

public static function createAccessInstance()
{
Access::setSingletonInstance($access = new Test_Access_OverrideLogin());
Expand Down Expand Up @@ -47,13 +49,7 @@ public static function setUpBeforeClass()
API::getInstance()->get(static::$fixture->idSite, 'year', $date);

// make sure processed & expected dirs exist
list($processedDir, $expectedDir) = self::getProcessedAndExpectedDirs();
if (!is_dir($processedDir)) {
mkdir($processedDir);
}
if (!is_dir($expectedDir)) {
mkdir($expectedDir);
}
self::makeDirsAndLinks();

// run slimerjs/phantomjs w/ all urls so we only invoke it once
$urls = array();
Expand All @@ -74,6 +70,8 @@ public static function tearDownAfterClass()
unlink("C:\\nppdf32Log\\debuglog.txt");
}

self::removeRecursiveLinks();

if (!Zend_Registry::get('db')) {
Piwik::createDatabaseObject();
}
Expand Down Expand Up @@ -175,4 +173,31 @@ public static function getProxyUrl()
{
return Test_Piwik_BaseFixture::getRootUrl() . 'tests/PHPUnit/proxy/index.php';
}

private static function makeDirsAndLinks()
{
$dirs = self::getProcessedAndExpectedDirs();
foreach ($dirs as $dir) {
if (!is_dir($dir)) {
mkdir($dir);
}
}

foreach (self::$recursiveProxyLinkNames as $linkName) {
$linkPath = PIWIK_INCLUDE_PATH . '/tests/PHPUnit/proxy/' . $linkName;
if (!file_exists($linkPath)) {
symlink(PIWIK_INCLUDE_PATH . '/' . $linkName, $linkPath);
}
}
}

private static function removeRecursiveLinks()
{
foreach (self::$recursiveProxyLinkNames as $linkName) {
$wholePath = PIWIK_INCLUDE_PATH . '/tests/PHPUnit/proxy/' . $linkName;
if (file_exists($wholePath)) {
unlink($wholePath);
}
}
}
}
1 change: 0 additions & 1 deletion tests/PHPUnit/proxy/libs

This file was deleted.

1 change: 0 additions & 1 deletion tests/PHPUnit/proxy/plugins

This file was deleted.

1 change: 0 additions & 1 deletion tests/PHPUnit/proxy/tests

This file was deleted.

0 comments on commit 01e5881

Please sign in to comment.