File tree Expand file tree Collapse file tree 2 files changed +8
-22
lines changed
tests/Unit/Factory/DbalFactory Expand file tree Collapse file tree 2 files changed +8
-22
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,11 @@ public function __construct(
15
15
) {
16
16
}
17
17
18
- public function create (array | DatabaseConfig $ dbalConfig ): DatabaseManager
18
+ public function create (array $ dbalConfig ): DatabaseManager
19
19
{
20
20
$ loggingEnabled = $ dbalConfig ['query-logging ' ] ?? false ;
21
21
$ dbal = new DatabaseManager (
22
- $ this -> prepareConfig ($ dbalConfig )
22
+ new DatabaseConfig ($ dbalConfig )
23
23
);
24
24
25
25
if ($ this ->logger !== null && $ loggingEnabled === true ) {
@@ -30,17 +30,4 @@ public function create(array|DatabaseConfig $dbalConfig): DatabaseManager
30
30
return $ dbal ;
31
31
}
32
32
33
- /**
34
- * @param array|DatabaseConfig $config
35
- *
36
- * @return DatabaseConfig
37
- */
38
- private function prepareConfig (array |DatabaseConfig $ config ): DatabaseConfig
39
- {
40
- if ($ config instanceof DatabaseConfig) {
41
- return $ config ;
42
- }
43
-
44
- return new DatabaseConfig ($ config );
45
- }
46
33
}
Original file line number Diff line number Diff line change 5
5
namespace Yiisoft \Yii \Cycle \Tests \Unit \Factory \DbalFactory ;
6
6
7
7
use Cycle \Database \Config \DatabaseConfig ;
8
+ use Cycle \Database \Database ;
9
+ use Cycle \Database \DatabaseManager ;
8
10
use Yiisoft \Yii \Cycle \Factory \DbalFactory ;
9
11
use Yiisoft \Yii \Cycle \Tests \Unit \Stub \FakeConnectionConfig ;
10
12
use Yiisoft \Yii \Cycle \Tests \Unit \Stub \FakeDriver ;
11
13
use Yiisoft \Yii \Cycle \Tests \Unit \Stub \FakeDriverConfig ;
12
14
13
15
final class DbalFactoryTest extends BaseDbalFactory
14
16
{
15
- public function testPrepareConfig (): void
17
+ public function testCreate (): void
16
18
{
17
19
$ config = [
18
20
'query-logging ' => true ,
@@ -30,12 +32,9 @@ public function testPrepareConfig(): void
30
32
];
31
33
32
34
$ factory = new DbalFactory ();
33
- $ ref = new \ ReflectionMethod ( $ factory, ' prepareConfig ' );
34
- $ ref -> setAccessible ( true );
35
+ $ dbal = $ factory-> create ( $ config );
36
+ $ dbalConfig = new DatabaseConfig ( $ config );
35
37
36
- $ this ->assertEquals (new DatabaseConfig ($ config ), $ ref ->invoke ($ factory , $ config ));
37
-
38
- $ obj = new DatabaseConfig ($ config );
39
- $ this ->assertSame ($ obj , $ ref ->invoke ($ factory , $ obj ));
38
+ $ this ->assertSame ($ dbal ->database ()->getName (), $ dbalConfig ->getDefaultDatabase ());
40
39
}
41
40
}
You can’t perform that action at this time.
0 commit comments