1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* graviton test case |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Graviton\TestBundle\Test; |
7
|
|
|
|
8
|
|
|
use Graviton\AppKernel; |
9
|
|
|
use Graviton\BundleBundle\GravitonBundleBundle; |
10
|
|
|
use Graviton\BundleBundle\Loader\BundleLoader; |
11
|
|
|
use Liip\FunctionalTestBundle\Test\WebTestCase; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Graviton test case |
15
|
|
|
* |
16
|
|
|
* Override creating a kernel with our custom bundle-bundle routine. |
17
|
|
|
* |
18
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
19
|
|
|
* @license https://opensource.org/licenses/MIT MIT License |
20
|
|
|
* @link http://swisscom.ch |
21
|
|
|
*/ |
22
|
|
|
class GravitonTestCase extends WebTestCase |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
use PrivateClassMethodTrait; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* return our namespaced AppKernel |
29
|
|
|
* |
30
|
|
|
* Most symfony projects keep their AppKernel class in phps |
31
|
|
|
* global space. Since we don't this needs to be overridden. |
32
|
|
|
* |
33
|
|
|
* This also allows us to properly set up the BundleLoader |
34
|
|
|
* infrastucture. This isn't in the DIC since it is used to |
35
|
|
|
* bootstrap the DIC itself. |
36
|
|
|
* |
37
|
|
|
* @param array $options array of options, default: empty, currently ignored |
38
|
|
|
* |
39
|
|
|
* @return \Graviton\AppKernel |
40
|
|
|
*/ |
41
|
8 |
|
public static function createKernel(array $options = array()) |
42
|
|
|
{ |
43
|
8 |
|
include_once __DIR__ . '/../../../../app/AppKernel.php'; |
44
|
|
|
|
45
|
8 |
|
$env = 'test'; |
46
|
8 |
|
$debug = false; |
47
|
|
|
|
48
|
8 |
|
$kernel = new AppKernel($env, $debug); |
49
|
8 |
|
$kernel->setBundleLoader(new BundleLoader(new GravitonBundleBundle())); |
50
|
8 |
|
$kernel->boot(); |
51
|
|
|
|
52
|
|
|
//set error reporting for phpunit |
53
|
8 |
|
ini_set('error_reporting', E_ALL); |
54
|
|
|
|
55
|
8 |
|
return $kernel; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Provides a test double for the named calss. |
60
|
|
|
* |
61
|
|
|
* @param string $class Full namespace of the class to be doubled |
62
|
|
|
* @param array $methods List of methods to be doubled |
63
|
|
|
* |
64
|
|
|
* @return \PHPUnit_Framework_MockObject_MockObject |
65
|
|
|
*/ |
66
|
|
|
public function getSimpleTestDouble($class, array $methods = array()) |
67
|
|
|
{ |
68
|
|
|
return $this->getMockBuilder($class) |
69
|
|
|
->disableOriginalConstructor() |
70
|
|
|
->setMethods($methods) |
71
|
|
|
->getMock(); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|