@@ -46,24 +46,32 @@ public function __construct(array $params)
4646 if (empty ($ params )) {
4747 throw new TestingException ('Configuration parameters are empty ' );
4848 }
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 ]);
5156 }
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 ]);
5664 }
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 );
6775 }
6876
6977 public function getPDODSN (): string
@@ -83,7 +91,7 @@ public function getPDOPassword(): string
8391
8492 public function getPDOFixtures (): array
8593 {
86- return $ this ->PDOParams ['fixtures ' ];
94+ return isset ( $ this ->PDOParams ['fixtures ' ]) ? $ this -> PDOParams [ ' fixtures ' ] : [ ];
8795 }
8896
8997 public function getAMQPHost (): string
@@ -113,6 +121,6 @@ public function getAMQPVhost(): string
113121
114122 public function getAMQPFixtures (): array
115123 {
116- return $ this ->AMQPParams ['fixtures ' ];
124+ return isset ( $ this ->AMQPParams ['fixtures ' ]) ? $ this -> AMQPParams [ ' fixtures ' ] : [ ];
117125 }
118126}
0 commit comments