4
4
5
5
namespace MySQLReplication \Tests \Integration ;
6
6
7
+ use Generator ;
7
8
use MySQLReplication \Definitions \ConstEventType ;
8
9
use MySQLReplication \Event \DTO \QueryDTO ;
9
10
use MySQLReplication \Event \DTO \RowsQueryDTO ;
11
+ use PHPUnit \Framework \Attributes \DataProvider ;
10
12
11
13
final class RowsQueryTest extends BaseCase
12
14
{
13
- public function testThatTheEditingQueryIsReadFromBinLog (): void
15
+ #[DataProvider('provideQueries ' )]
16
+ public function testThatTheEditingQueryIsReadFromBinLog (string $ query ): void
14
17
{
15
18
$ this ->connection ->executeStatement (
16
19
'CREATE TABLE test (id INT NOT NULL AUTO_INCREMENT, data VARCHAR (50) NOT NULL, PRIMARY KEY (id)) '
17
20
);
18
21
19
- $ insertQuery = 'INSERT INTO test (data) VALUES( \'Hello \') /* Foo:Bar; */ ' ;
20
- $ this ->connection ->executeStatement ($ insertQuery );
22
+ $ this ->connection ->executeStatement ($ query );
21
23
22
24
// The Create Table Query ... irrelevant content for this test
23
25
self ::assertInstanceOf (QueryDTO::class, $ this ->getEvent ());
@@ -26,7 +28,15 @@ public function testThatTheEditingQueryIsReadFromBinLog(): void
26
28
27
29
$ rowsQueryEvent = $ this ->getEvent ();
28
30
self ::assertInstanceOf (RowsQueryDTO::class, $ rowsQueryEvent );
29
- self ::assertSame ($ insertQuery , $ rowsQueryEvent ->query );
31
+ self ::assertSame ($ query , $ rowsQueryEvent ->query );
32
+ }
33
+
34
+ public static function provideQueries (): Generator
35
+ {
36
+ yield 'Short Query ' => ['INSERT INTO test (data) VALUES( \'Hello \') /* Foo:Bar; */ ' ];
37
+
38
+ $ comment = '/* Foo:Bar; Bar:Baz; Baz:Quo; Quo:Foo; Quo:Foo; Quo:Foo; Quo:Foo; Foo:Baz; */ ' ;
39
+ yield 'Extra Long Query ' => [$ comment . ' INSERT INTO test (data) VALUES( \'Hello \') ' . $ comment ];
30
40
}
31
41
32
42
protected function getIgnoredEvents (): array
0 commit comments