@@ -17,8 +17,6 @@ public function testSelectStaticText()
17
17
$ this ->assertCount (1 , $ command ->resultRows );
18
18
$ this ->assertCount (1 , $ command ->resultRows [0 ]);
19
19
$ this ->assertSame ('foo ' , reset ($ command ->resultRows [0 ]));
20
-
21
- $ this ->assertInstanceOf ('React\MySQL\Connection ' , $ conn );
22
20
});
23
21
24
22
$ connection ->quit ();
@@ -57,7 +55,7 @@ public function testSelectStaticValueWillBeReturnedAsIs($value)
57
55
$ this ->assertCount (1 , $ command ->resultRows );
58
56
$ this ->assertCount (1 , $ command ->resultRows [0 ]);
59
57
$ this ->assertSame ($ expected , reset ($ command ->resultRows [0 ]));
60
- })-> then ( null , ' printf ' ) ;
58
+ });
61
59
62
60
$ connection ->quit ();
63
61
Loop::run ();
@@ -82,7 +80,7 @@ public function testSelectStaticValueWillBeReturnedAsIsWithNoBackslashEscapesSql
82
80
$ this ->assertCount (1 , $ command ->resultRows );
83
81
$ this ->assertCount (1 , $ command ->resultRows [0 ]);
84
82
$ this ->assertSame ($ expected , reset ($ command ->resultRows [0 ]));
85
- })-> then ( null , ' printf ' ) ;
83
+ });
86
84
87
85
$ connection ->quit ();
88
86
Loop::run ();
@@ -138,7 +136,7 @@ public function testSelectLongStaticTextHasTypeStringWithValidLength()
138
136
139
137
$ connection ->query ('SELECT ? ' , [$ value ])->then (function (QueryResult $ command ) use ($ length ) {
140
138
$ this ->assertCount (1 , $ command ->resultFields );
141
- $ this ->assertEquals ($ length * 3 , $ command ->resultFields [0 ]['length ' ]);
139
+ $ this ->assertEquals ($ length * 4 , $ command ->resultFields [0 ]['length ' ]);
142
140
$ this ->assertSame (Constants::FIELD_TYPE_VAR_STRING , $ command ->resultFields [0 ]['type ' ]);
143
141
});
144
142
@@ -430,7 +428,7 @@ public function testInvalidSelectShouldFail()
430
428
431
429
$ connection ->query ('select * from invalid_table ' )->then (
432
430
$ this ->expectCallableNever (),
433
- function (\Exception $ error ) {
431
+ function (\Exception $ error ) use ( $ db ) {
434
432
$ this ->assertEquals ("Table ' $ db.invalid_table' doesn't exist " , $ error ->getMessage ());
435
433
}
436
434
);
@@ -446,7 +444,13 @@ public function testInvalidMultiStatementsShouldFailToPreventSqlInjections()
446
444
$ connection ->query ('select 1;select 2; ' )->then (
447
445
$ this ->expectCallableNever (),
448
446
function (\Exception $ error ) {
449
- $ this ->assertContains ("You have an error in your SQL syntax " , $ error ->getMessage ());
447
+ if (method_exists ($ this , 'assertStringContainsString ' )) {
448
+ // PHPUnit 9+
449
+ $ this ->assertStringContainsString ("You have an error in your SQL syntax " , $ error ->getMessage ());
450
+ } else {
451
+ // legacy PHPUnit < 9
452
+ $ this ->assertContains ("You have an error in your SQL syntax " , $ error ->getMessage ());
453
+ }
450
454
}
451
455
);
452
456
0 commit comments