1313
1414class TransactionManagerTest extends TestCase
1515{
16- const URI = 'mysql://root:password@127.0.0.1 ' ;
1716 /**
1817 * @var TransactionManager
1918 */
@@ -22,24 +21,18 @@ class TransactionManagerTest extends TestCase
2221 public function setUp (): void
2322 {
2423 $ this ->object = new TransactionManager ();
25-
26- $ dbDriver = Factory::getDbInstance (self ::URI );
27- $ dbDriver ->execute ('create database if not exists a; ' );
28- $ dbDriver ->execute ('create database if not exists b; ' );
29- $ dbDriver ->execute ('create database if not exists c; ' );
30- $ dbDriver ->execute ('create database if not exists d; ' );
3124 }
3225
3326 public function tearDown (): void
3427 {
3528 $ this ->object ->destroy ();
3629 $ this ->object = null ;
3730
38- $ dbDriver = Factory:: getDbInstance ( self :: URI . " / a " );
31+ $ dbDriver = ConnectionUtil:: getConnection ( " a " );
3932 $ dbDriver ->execute ('drop table if exists users; ' );
4033 $ dbDriver ->execute ('drop table if exists users1; ' );
4134
42- $ dbDriver = Factory:: getDbInstance ( self :: URI . " / b " );
35+ $ dbDriver = ConnectionUtil:: getConnection ( " b " );
4336 $ dbDriver ->execute ('drop table if exists users2; ' );
4437 }
4538
@@ -48,16 +41,16 @@ public function testAddConnectionError()
4841 $ this ->expectException (InvalidArgumentException::class);
4942 $ this ->expectExceptionMessage ("The connection already exists with a different instance " );
5043
51- $ dbDrive1 = $ this ->object ->addConnection (self :: URI . " /a " );
52- $ dbDrive2 = $ this ->object ->addConnection (self :: URI . " /b " );
53- $ dbDrive3 = $ this ->object ->addConnection (self :: URI . " /a " );
54- $ dbDrive4 = $ this ->object ->addConnection (self :: URI . " /b " );
44+ $ dbDrive1 = $ this ->object ->addConnection (ConnectionUtil:: getUri ( " a " ) );
45+ $ dbDrive2 = $ this ->object ->addConnection (ConnectionUtil:: getUri ( " b " ) );
46+ $ dbDrive3 = $ this ->object ->addConnection (ConnectionUtil:: getUri ( " a " ) );
47+ $ dbDrive4 = $ this ->object ->addConnection (ConnectionUtil:: getUri ( " b " ) );
5548 }
5649
5750 public function testAddConnection ()
5851 {
59- $ dbDrive1 = $ this ->object ->addConnection (self :: URI . " /a " );
60- $ dbDrive2 = $ this ->object ->addConnection (self :: URI . " /b " );
52+ $ dbDrive1 = $ this ->object ->addConnection (ConnectionUtil:: getUri ( " a " ) );
53+ $ dbDrive2 = $ this ->object ->addConnection (ConnectionUtil:: getUri ( " b " ) );
6154 $ this ->object ->addDbDriver ($ dbDrive1 );
6255 $ this ->object ->addDbDriver ($ dbDrive2 );
6356
@@ -71,10 +64,10 @@ public function testAddDbDriverError()
7164 $ this ->expectException (InvalidArgumentException::class);
7265 $ this ->expectExceptionMessage ("The connection already exists with a different instance " );
7366
74- $ dbDrive1 = Factory::getDbInstance (self :: URI . " /a " );
75- $ dbDrive2 = Factory::getDbInstance (self :: URI . " /b " );
76- $ dbDrive3 = Factory::getDbInstance (self :: URI . " /a " );
77- $ dbDrive4 = Factory::getDbInstance (self :: URI . " /b " );
67+ $ dbDrive1 = Factory::getDbInstance (ConnectionUtil:: getUri ( " a " ) );
68+ $ dbDrive2 = Factory::getDbInstance (ConnectionUtil:: getUri ( " b " ) );
69+ $ dbDrive3 = Factory::getDbInstance (ConnectionUtil:: getUri ( " a " ) );
70+ $ dbDrive4 = Factory::getDbInstance (ConnectionUtil:: getUri ( " b " ) );
7871
7972 $ this ->object ->addDbDriver ($ dbDrive1 );
8073 $ this ->object ->addDbDriver ($ dbDrive2 );
@@ -84,8 +77,8 @@ public function testAddDbDriverError()
8477
8578 public function testAddDbDriver ()
8679 {
87- $ dbDrive1 = Factory:: getDbInstance ( self :: URI . " / a " );
88- $ dbDrive2 = Factory:: getDbInstance ( self :: URI . " / b " );
80+ $ dbDrive1 = ConnectionUtil:: getConnection ( " a " );
81+ $ dbDrive2 = ConnectionUtil:: getConnection ( " b " );
8982
9083 $ this ->object ->addDbDriver ($ dbDrive1 );
9184 $ this ->object ->addDbDriver ($ dbDrive2 );
@@ -99,7 +92,7 @@ public function testAddDbDriver()
9992
10093 public function testAddRepository ()
10194 {
102- $ dbDriver = Factory:: getDbInstance ( self :: URI . " / a " );
95+ $ dbDriver = ConnectionUtil:: getConnection ( " a " );
10396
10497 $ dbDriver ->execute ('create table users (
10598 id integer primary key auto_increment,
@@ -121,8 +114,8 @@ public function testAddRepository()
121114
122115 public function testBeginTransaction ()
123116 {
124- $ this ->object ->addConnection (self :: URI . " /c " );
125- $ this ->object ->addConnection (self :: URI . " /d " );
117+ $ this ->object ->addConnection (ConnectionUtil:: getUri ( " c " ) );
118+ $ this ->object ->addConnection (ConnectionUtil:: getUri ( " d " ) );
126119
127120 $ this ->object ->beginTransaction ();
128121 $ this ->object ->commitTransaction ();
@@ -135,8 +128,8 @@ public function testBeginTransactionTwice()
135128 $ this ->expectException (TransactionException::class);
136129 $ this ->expectExceptionMessage ("Transaction Already Started " );
137130
138- $ this ->object ->addConnection (self :: URI . " /a " );
139- $ this ->object ->addConnection (self :: URI . " /d " );
131+ $ this ->object ->addConnection (ConnectionUtil:: getUri ( " a " ) );
132+ $ this ->object ->addConnection (ConnectionUtil:: getUri ( " d " ) );
140133
141134 $ this ->assertEquals (2 , $ this ->object ->count ());
142135
@@ -149,7 +142,7 @@ public function testRollbackWithNoTransaction()
149142 $ this ->expectException (TransactionException::class);
150143 $ this ->expectExceptionMessage ("There is no Active Transaction " );
151144
152- $ this ->object ->addConnection (self :: URI . " /c " );
145+ $ this ->object ->addConnection (ConnectionUtil:: getUri ( " c " ) );
153146 $ this ->assertEquals (1 , $ this ->object ->count ());
154147 $ this ->object ->rollbackTransaction ();
155148 }
@@ -159,15 +152,15 @@ public function testCommitWithNoTransaction()
159152 $ this ->expectException (TransactionException::class);
160153 $ this ->expectExceptionMessage ("There is no Active Transaction " );
161154
162- $ this ->object ->addConnection (self :: URI . " /d " );
155+ $ this ->object ->addConnection (ConnectionUtil:: getUri ( " d " ) );
163156 $ this ->assertEquals (1 , $ this ->object ->count ());
164157 $ this ->object ->commitTransaction ();
165158 }
166159
167160 public function testTransaction ()
168161 {
169- $ dbDrive1 = Factory:: getDbInstance ( self :: URI . " / a " );
170- $ dbDrive2 = Factory:: getDbInstance ( self :: URI . " / b " );
162+ $ dbDrive1 = ConnectionUtil:: getConnection ( " a " );
163+ $ dbDrive2 = ConnectionUtil:: getConnection ( " b " );
171164
172165 $ dbDrive1 ->execute ('create table users1 (
173166 id integer primary key auto_increment,
0 commit comments