44
55namespace MySQLReplication \Tests \Integration ;
66
7+ use Generator ;
78use MySQLReplication \Definitions \ConstEventType ;
89use MySQLReplication \Event \DTO \QueryDTO ;
910use MySQLReplication \Event \DTO \RowsQueryDTO ;
11+ use PHPUnit \Framework \Attributes \DataProvider ;
1012
1113final class RowsQueryTest extends BaseCase
1214{
13- public function testThatTheEditingQueryIsReadFromBinLog (): void
15+ #[DataProvider('provideQueries ' )]
16+ public function testThatTheEditingQueryIsReadFromBinLog (string $ query ): void
1417 {
1518 $ this ->connection ->executeStatement (
1619 'CREATE TABLE test (id INT NOT NULL AUTO_INCREMENT, data VARCHAR (50) NOT NULL, PRIMARY KEY (id)) '
1720 );
1821
19- $ insertQuery = 'INSERT INTO test (data) VALUES( \'Hello \') /* Foo:Bar; */ ' ;
20- $ this ->connection ->executeStatement ($ insertQuery );
22+ $ this ->connection ->executeStatement ($ query );
2123
2224 // The Create Table Query ... irrelevant content for this test
2325 self ::assertInstanceOf (QueryDTO::class, $ this ->getEvent ());
@@ -26,7 +28,15 @@ public function testThatTheEditingQueryIsReadFromBinLog(): void
2628
2729 $ rowsQueryEvent = $ this ->getEvent ();
2830 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 ];
3040 }
3141
3242 protected function getIgnoredEvents (): array
0 commit comments