Skip to content

Commit 3f41237

Browse files
committed
current changes
1 parent bca95ef commit 3f41237

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

tests/Integration/BasicTest.php

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ public function shouldDropColumn()
122122
{
123123
$this->disconnect();
124124

125-
$this->configBuilder->withEventsOnly([ConstEventType::WRITE_ROWS_EVENT_V1, ConstEventType::WRITE_ROWS_EVENT_V2]);
125+
$this->configBuilder->withEventsOnly(
126+
[ConstEventType::WRITE_ROWS_EVENT_V1, ConstEventType::WRITE_ROWS_EVENT_V2]
127+
);
126128

127129
$this->connect();
128130

@@ -140,4 +142,63 @@ public function shouldDropColumn()
140142
self::assertInstanceOf(WriteRowsDTO::class, $event);
141143
self::assertEquals(['id' => 2], $event->getValues()[0]);
142144
}
145+
146+
/**
147+
* @test
148+
*/
149+
public function shouldFilterEvents()
150+
{
151+
$this->disconnect();
152+
153+
$this->configBuilder->withEventsOnly([ConstEventType::QUERY_EVENT]);
154+
155+
$this->connect();
156+
157+
self::assertInstanceOf(QueryDTO::class, $this->getEvent());
158+
self::assertInstanceOf(QueryDTO::class, $this->getEvent());
159+
160+
$this->connection->exec($createTableExpected = 'CREATE TABLE test (id INTEGER(11), data VARCHAR(50))');
161+
162+
/** @var QueryDTO $event */
163+
$event = $this->getEvent();
164+
self::assertInstanceOf(QueryDTO::class, $event);
165+
self::assertEquals($createTableExpected, $event->getQuery());
166+
}
167+
168+
/**
169+
* @test
170+
*/
171+
public function shouldFilterTables()
172+
{
173+
$expectedTable = 'test_2';
174+
$expectedValue = 'foobar';
175+
176+
$this->disconnect();
177+
178+
$this->configBuilder
179+
->withEventsOnly(
180+
[ConstEventType::WRITE_ROWS_EVENT_V1, ConstEventType::WRITE_ROWS_EVENT_V2]
181+
)->withTablesOnly([$expectedTable]);
182+
183+
$this->connect();
184+
185+
$this->connection->exec('CREATE TABLE test_2 (id INT NOT NULL AUTO_INCREMENT, data VARCHAR (50) NOT NULL, PRIMARY KEY (id))');
186+
$this->connection->exec('CREATE TABLE test_3 (id INT NOT NULL AUTO_INCREMENT, data VARCHAR (50) NOT NULL, PRIMARY KEY (id))');
187+
$this->connection->exec('CREATE TABLE test_4 (id INT NOT NULL AUTO_INCREMENT, data VARCHAR (50) NOT NULL, PRIMARY KEY (id))');
188+
189+
190+
$this->connection->exec('INSERT INTO test_4 (data) VALUES (\'foo\')');
191+
$this->connection->exec('INSERT INTO test_3 (data) VALUES (\'bar\')');
192+
$this->connection->exec('INSERT INTO test_2 (data) VALUES (\''. $expectedValue .'\')');
193+
194+
/** @var WriteRowsDTO $event */
195+
$event = $this->getEvent();
196+
self::assertInstanceOf(WriteRowsDTO::class, $event);
197+
self::assertEquals($expectedTable, $event->getTableMap()->getTable());
198+
self::assertEquals($expectedValue, $event->getValues()[0]['data']);
199+
}
200+
201+
202+
203+
143204
}

0 commit comments

Comments
 (0)