1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Slim3 Doctrine integration (https://github.com/juliangut/slim-doctrine) |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/juliangut/slim-doctrine for the canonical source repository |
6
|
|
|
* |
7
|
|
|
* @license https://raw.githubusercontent.com/juliangut/slim-doctrine/master/LICENSE |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Jgut\Slim\Doctrine\Tests; |
11
|
|
|
|
12
|
|
|
use Jgut\Slim\Doctrine\CLIApplicationBuilder; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @covers Jgut\Slim\Doctrine\CLIApplicationBuilder |
16
|
|
|
*/ |
17
|
|
|
class CLIApplicationBuilderTest extends \PHPUnit_Framework_TestCase |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @expectedException \InvalidArgumentException |
21
|
|
|
*/ |
22
|
|
|
public function testNoEntityManager() |
23
|
|
|
{ |
24
|
|
|
CLIApplicationBuilder::build(''); |
|
|
|
|
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function testOnlyEntityManager() |
28
|
|
|
{ |
29
|
|
|
$entityOptions = [ |
30
|
|
|
'connection' => [ |
31
|
|
|
'driver' => 'pdo_sqlite', |
32
|
|
|
'memory' => true, |
33
|
|
|
], |
34
|
|
|
'annotation_paths' => sys_get_temp_dir(), |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
$application = CLIApplicationBuilder::build($entityOptions); |
38
|
|
|
|
39
|
|
|
self::assertInstanceOf('Symfony\Component\Console\Application', $application); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @expectedException \InvalidArgumentException |
44
|
|
|
*/ |
45
|
|
|
public function testNoDocumentManager() |
46
|
|
|
{ |
47
|
|
|
$entityOptions = [ |
48
|
|
|
'connection' => [ |
49
|
|
|
'driver' => 'pdo_sqlite', |
50
|
|
|
'memory' => true, |
51
|
|
|
], |
52
|
|
|
'annotation_paths' => sys_get_temp_dir(), |
53
|
|
|
]; |
54
|
|
|
|
55
|
|
|
CLIApplicationBuilder::build($entityOptions, ''); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function testBothManagers() |
59
|
|
|
{ |
60
|
|
|
$entityOptions = [ |
61
|
|
|
'connection' => [ |
62
|
|
|
'driver' => 'pdo_sqlite', |
63
|
|
|
'memory' => true, |
64
|
|
|
], |
65
|
|
|
'annotation_paths' => sys_get_temp_dir(), |
66
|
|
|
]; |
67
|
|
|
$documentOptions = [ |
68
|
|
|
'connection' => [ |
69
|
|
|
'server' => 'mongodb://localhost:27017', |
70
|
|
|
], |
71
|
|
|
'annotation_paths' => sys_get_temp_dir(), |
72
|
|
|
]; |
73
|
|
|
|
74
|
|
|
$application = CLIApplicationBuilder::build($entityOptions, $documentOptions); |
75
|
|
|
|
76
|
|
|
self::assertInstanceOf('Symfony\Component\Console\Application', $application); |
77
|
|
|
self::assertTrue($application->has('odm:generate:documents')); |
78
|
|
|
self::assertTrue($application->has('odm:generate:hydrators')); |
79
|
|
|
self::assertTrue($application->has('odm:generate:proxies')); |
80
|
|
|
self::assertTrue($application->has('odm:generate:repositories')); |
81
|
|
|
self::assertTrue($application->has('odm:clear-cache:metadata')); |
82
|
|
|
self::assertTrue($application->has('odm:schema:create')); |
83
|
|
|
self::assertTrue($application->has('odm:schema:drop')); |
84
|
|
|
self::assertTrue($application->has('odm:schema:update')); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: