@@ -46,24 +46,32 @@ public function __construct(array $params)
46
46
if (empty ($ params )) {
47
47
throw new TestingException ('Configuration parameters are empty ' );
48
48
}
49
- if (!isset ($ params [self ::PDO_KEY ])) {
50
- $ params [self ::PDO_KEY ] = [];
49
+ if (isset ($ params [self ::PDO_KEY ])) {
50
+ if ($ invalidConfigParams = array_diff_key ($ params [self ::PDO_KEY ], self ::$ defaultPDOParams )) {
51
+ throw new TestingException (
52
+ 'The following elements are not valid PDO configuration params: ' . json_encode ($ invalidConfigParams )
53
+ );
54
+ }
55
+ $ this ->PDOParams = array_merge (self ::$ defaultPDOParams , $ params [self ::PDO_KEY ]);
51
56
}
52
- if ($ invalidConfigParams = array_diff_key ($ params [self ::PDO_KEY ], self ::$ defaultPDOParams )) {
53
- throw new TestingException (
54
- 'The following elements are not valid PDO configuration params: ' . json_encode ($ invalidConfigParams )
55
- );
57
+ if (isset ($ params [self ::AMQP_KEY ])) {
58
+ if ($ invalidConfigParams = array_diff_key ($ params [self ::AMQP_KEY ], self ::$ defaultAMQPParams )) {
59
+ throw new TestingException (
60
+ 'The following elements are not valid AMQP configuration params: ' . json_encode ($ invalidConfigParams )
61
+ );
62
+ }
63
+ $ this ->AMQPParams = array_merge (self ::$ defaultAMQPParams , $ params [self ::AMQP_KEY ]);
56
64
}
57
- if (! isset ( $ params [ self :: AMQP_KEY ])) {
58
- $ params [ self :: AMQP_KEY ] = [];
59
- }
60
- if ( $ invalidConfigParams = array_diff_key ( $ params [ self :: AMQP_KEY ], self :: $ defaultAMQPParams )) {
61
- throw new TestingException (
62
- ' The following elements are not valid AMQP configuration params: ' . json_encode ( $ invalidConfigParams )
63
- );
64
- }
65
- $ this -> PDOParams = array_merge ( self :: $ defaultPDOParams , $ params [ self :: PDO_KEY ]);
66
- $ this ->AMQPParams = array_merge ( self :: $ defaultAMQPParams , $ params [ self :: AMQP_KEY ] );
65
+ }
66
+
67
+ public function hasPDOFixtures (): bool
68
+ {
69
+ return ! empty ( $ this -> PDOParams );
70
+ }
71
+
72
+ public function hasAMQPFixtures (): bool
73
+ {
74
+ return ! empty ( $ this ->AMQPParams );
67
75
}
68
76
69
77
public function getPDODSN (): string
@@ -83,7 +91,7 @@ public function getPDOPassword(): string
83
91
84
92
public function getPDOFixtures (): array
85
93
{
86
- return $ this ->PDOParams ['fixtures ' ];
94
+ return isset ( $ this ->PDOParams ['fixtures ' ]) ? $ this -> PDOParams [ ' fixtures ' ] : [ ];
87
95
}
88
96
89
97
public function getAMQPHost (): string
@@ -113,6 +121,6 @@ public function getAMQPVhost(): string
113
121
114
122
public function getAMQPFixtures (): array
115
123
{
116
- return $ this ->AMQPParams ['fixtures ' ];
124
+ return isset ( $ this ->AMQPParams ['fixtures ' ]) ? $ this -> AMQPParams [ ' fixtures ' ] : [ ];
117
125
}
118
126
}
0 commit comments