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 testNoManagers() |
23
|
|
|
{ |
24
|
|
|
CLIApplicationBuilder::build(); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @expectedException \InvalidArgumentException |
29
|
|
|
*/ |
30
|
|
|
public function testBadEntityManagers() |
31
|
|
|
{ |
32
|
|
|
CLIApplicationBuilder::build(''); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testEntityManager() |
36
|
|
|
{ |
37
|
|
|
$entityOptions = [ |
38
|
|
|
'connection' => [ |
39
|
|
|
'driver' => 'pdo_sqlite', |
40
|
|
|
'memory' => true, |
41
|
|
|
], |
42
|
|
|
'annotation_paths' => sys_get_temp_dir(), |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
$application = CLIApplicationBuilder::build($entityOptions); |
46
|
|
|
|
47
|
|
|
self::assertInstanceOf('Symfony\Component\Console\Application', $application); |
48
|
|
|
self::assertTrue($application->has('orm:schema-tool:create')); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @expectedException \InvalidArgumentException |
53
|
|
|
*/ |
54
|
|
|
public function testBadDocumentManagers() |
55
|
|
|
{ |
56
|
|
|
CLIApplicationBuilder::build(null, ''); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function testDocumentManagers() |
60
|
|
|
{ |
61
|
|
|
$documentOptions = [ |
62
|
|
|
'connection' => [ |
63
|
|
|
'server' => 'mongodb://localhost:27017', |
64
|
|
|
], |
65
|
|
|
'annotation_paths' => sys_get_temp_dir(), |
66
|
|
|
]; |
67
|
|
|
|
68
|
|
|
$application = CLIApplicationBuilder::build(null, $documentOptions); |
69
|
|
|
|
70
|
|
|
self::assertInstanceOf('Symfony\Component\Console\Application', $application); |
71
|
|
|
self::assertTrue($application->has('odm:generate:documents')); |
72
|
|
|
self::assertTrue($application->has('odm:generate:hydrators')); |
73
|
|
|
self::assertTrue($application->has('odm:generate:proxies')); |
74
|
|
|
self::assertTrue($application->has('odm:generate:repositories')); |
75
|
|
|
self::assertTrue($application->has('odm:clear-cache:metadata')); |
76
|
|
|
self::assertTrue($application->has('odm:schema:create')); |
77
|
|
|
self::assertTrue($application->has('odm:schema:drop')); |
78
|
|
|
self::assertTrue($application->has('odm:schema:update')); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
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: