blob: 17a8b65ac4cdae58c80df91d24b8c2ee7b40991d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Tests\Framework\TestCase;
use Piwik\Application\Environment;
use Piwik\Tests\Framework\Mock\File;
/**
* Base class for Unit tests. Use this if you need to use the DI container in tests. It will be created fresh
* before each test.
*
* @deprecated Unit tests don't need no environment.
*
* @since 2.10.0
*/
abstract class UnitTestCase extends \PHPUnit_Framework_TestCase
{
/**
* @var Environment
*/
protected $environment;
public function setUp()
{
parent::setUp();
$this->initEnvironment();
File::reset();
}
public function tearDown()
{
File::reset();
// 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($environment = null, array(), $postBootstrappedEvent = false);
$nextTestEnviornment->init();
parent::tearDown();
}
/**
* Use this method to return custom container configuration that you want to apply for the tests.
*
* @return array
*/
protected function provideContainerConfig()
{
return array();
}
protected function initEnvironment()
{
$this->environment = new Environment($environment = null, $this->provideContainerConfig(), $postBootstrappedEvent = false);
$this->environment->init();
}
}
|