1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Vvval\Spiral\Tests; |
4
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
6
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
7
|
|
|
use Spiral\Core\Traits\SharedTrait; |
8
|
|
|
use Spiral\Pagination\PaginationFactory; |
9
|
|
|
use Spiral\Pagination\PaginatorsInterface; |
10
|
|
|
use Zend\Diactoros\ServerRequest; |
11
|
|
|
|
12
|
|
|
abstract class BaseTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
use SharedTrait; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var TestApplication |
18
|
|
|
*/ |
19
|
|
|
protected $app; |
20
|
|
|
|
21
|
|
|
public function setUp() |
22
|
|
|
{ |
23
|
|
|
$root = __DIR__ . '/-app-/'; |
24
|
|
|
$this->app = TestApplication::init( |
|
|
|
|
25
|
|
|
[ |
26
|
|
|
'root' => $root, |
27
|
|
|
'libraries' => dirname(__DIR__) . '/vendor/', |
28
|
|
|
'application' => $root, |
29
|
|
|
'framework' => dirname(__DIR__) . '/source/', |
30
|
|
|
'runtime' => $root . 'runtime/', |
31
|
|
|
'cache' => $root . 'runtime/cache/', |
32
|
|
|
], |
33
|
|
|
null, |
34
|
|
|
null, |
35
|
|
|
false |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
$this->app->container->bind('factory', $this->app->container); |
39
|
|
|
$this->app->container->bind(PaginatorsInterface::class, PaginationFactory::class); |
40
|
|
|
$this->app->container->bind(ServerRequestInterface::class, ServerRequest::class); |
41
|
|
|
|
42
|
|
|
clearstatcache(); |
43
|
|
|
|
44
|
|
|
//Open application scope |
45
|
|
|
TestApplication::shareContainer($this->app->container); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* This method performs full destroy of spiral environment. |
50
|
|
|
*/ |
51
|
|
|
public function tearDown() |
52
|
|
|
{ |
53
|
|
|
TestApplication::shareContainer(null); |
54
|
|
|
|
55
|
|
|
//Forcing destruction |
56
|
|
|
$this->app = null; |
57
|
|
|
|
58
|
|
|
gc_collect_cycles(); |
59
|
|
|
clearstatcache(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return \Spiral\Core\ContainerInterface |
64
|
|
|
*/ |
65
|
|
|
protected function iocContainer() |
66
|
|
|
{ |
67
|
|
|
return $this->app->container; |
68
|
|
|
} |
69
|
|
|
} |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..