Skip to content

Commit

Permalink
Fixing sleep for mutation. (#45)
Browse files Browse the repository at this point in the history
Signed-off-by: tianhe1986 <[email protected]>
  • Loading branch information
tianhe1986 authored Jul 19, 2021
1 parent c29de12 commit 067b2a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions tests/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1059,13 +1059,17 @@ public function testDelete()

$builder->newQuery()->table('test')->insertFile(['number'], new FileFromString('0'.PHP_EOL.'1'.PHP_EOL.'2'));

$result = $builder->newQuery()->table('test')->count();

$this->assertEquals(3, $result);

$builder->newQuery()->table('test')->where('number', '=', 1)->delete();

/*
* We have to sleep for 3 seconds while mutation in progress
*/
sleep(3);

$builder->newQuery()->table('test')->where('number', '=', 1)->delete();

$result = $builder->newQuery()->table('test')->count();

$this->assertEquals(2, $result);
Expand Down
8 changes: 6 additions & 2 deletions tests/LaravelIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,13 +548,17 @@ public function test_builder_delete()
new FileFromString('0'.PHP_EOL.'1'.PHP_EOL.'2'),
]);

$result = $connection->table('test')->select($connection->raw('count() as count'))->get();

$this->assertEquals(3, $result[0]['count']);

$connection->table('test')->where('number', '=', 1)->delete();

/*
* We have to sleep for 3 seconds while mutation in progress
*/
sleep(3);

$connection->table('test')->where('number', '=', 1)->delete();

$result = $connection->table('test')->select($connection->raw('count() as count'))->get();

$this->assertEquals(2, $result[0]['count']);
Expand Down

0 comments on commit 067b2a9

Please sign in to comment.