Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2015-04-06 02:15:57 +0300
committerdiosmosis <benaka@piwik.pro>2015-04-06 02:15:57 +0300
commit2c087e9c8e454747efb35c9fd22a815bd2093470 (patch)
tree3c840b8f5f9c4eb589eb6e857e88d637047623f3 /tests/PHPUnit/Framework/TestCase
parent3661b2c763438e4d64420d4b9c12d54f838469bb (diff)
Fixing unit tests, includes environment creation/destruction to UnitTestCase base class + ability to override environment in UnitTestCase.
Diffstat (limited to 'tests/PHPUnit/Framework/TestCase')
-rwxr-xr-xtests/PHPUnit/Framework/TestCase/UnitTestCase.php33
1 files changed, 31 insertions, 2 deletions
diff --git a/tests/PHPUnit/Framework/TestCase/UnitTestCase.php b/tests/PHPUnit/Framework/TestCase/UnitTestCase.php
index 8e07c39cc7..69347c99c7 100755
--- a/tests/PHPUnit/Framework/TestCase/UnitTestCase.php
+++ b/tests/PHPUnit/Framework/TestCase/UnitTestCase.php
@@ -7,10 +7,12 @@
*/
namespace Piwik\Tests\Framework\TestCase;
+
+use Piwik\Application\Environment;
+use Piwik\Container\StaticContainer;
use Piwik\EventDispatcher;
use Piwik\Tests\Framework\Mock\File;
-
/**
* Base class for Unit tests.
*
@@ -18,16 +20,43 @@ use Piwik\Tests\Framework\Mock\File;
*/
abstract class UnitTestCase extends \PHPUnit_Framework_TestCase
{
+ /**
+ * @var Environment
+ */
+ private $environment;
+
public function setUp()
{
parent::setUp();
+
+ $this->environment = new Environment('test', $this->provideContainerConfig());
+ $this->environment->init();
+
File::reset();
EventDispatcher::getInstance()->clearAllObservers();
}
public function tearDown()
{
- parent::tearDown();
File::reset();
+
+ StaticContainer::clearContainer();
+
+ // make sure the global container exists for the next test case that is executed (since logging can be done
+ // before a test sets up an environment)
+ $nextTestEnviornment = new Environment('test');
+ $nextTestEnviornment->init();
+
+ parent::tearDown();
+ }
+
+ /**
+ * TODO
+ *
+ * @return array
+ */
+ protected function provideContainerConfig()
+ {
+ return array();
}
}