Skip to content

Commit e6bafc5

Browse files
updated the catching exception cases in the tests
1 parent 46d97e2 commit e6bafc5

2 files changed

Lines changed: 10 additions & 30 deletions

File tree

tests/e2e/Adapter/Scopes/DocumentTests.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3560,12 +3560,8 @@ public function testUpdateDocuments(): void
35603560
throw new Exception("Error thrown to test update doesn't stopped and error is caught");
35613561
});
35623562
} catch (Exception $e) {
3563-
if ($e instanceof Exception) {
3564-
$this->assertInstanceOf(Exception::class, $e);
3565-
$this->assertEquals("Error thrown to test that deletion doesn't stop and error is caught", $e->getMessage());
3566-
} else {
3567-
$this->fail("Caught value is not an Exception.");
3568-
}
3563+
$this->assertInstanceOf(Exception::class, $e);
3564+
$this->assertEquals("Error thrown to test that update doesn't stop and error is caught", $e->getMessage());
35693565
}
35703566
$count = $database->updateDocuments($collection, new Document([
35713567
'string' => 'text📝 updated',
@@ -3575,12 +3571,8 @@ public function testUpdateDocuments(): void
35753571
$results[] = $doc;
35763572
throw new Exception("Error thrown to test update doesn't stopped and error is caught");
35773573
}, onError:function ($e) {
3578-
if ($e instanceof Exception) {
3579-
$this->assertInstanceOf(Exception::class, $e);
3580-
$this->assertEquals("Error thrown to test update doesn't stopped and error is caught", $e->getMessage());
3581-
} else {
3582-
$this->fail("Caught value is not an Exception.");
3583-
}
3574+
$this->assertInstanceOf(Exception::class, $e);
3575+
$this->assertEquals("Error thrown to test update doesn't stopped and error is caught", $e->getMessage());
35843576
});
35853577

35863578
$this->assertEquals(5, $count);

tests/e2e/Adapter/Scopes/RelationshipTests.php

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,12 +1794,8 @@ public function testUpdateDocumentsRelationships(): void
17941794
]), onNext: function () {
17951795
throw new Exception("Error thrown to test update doesn't stopped and error is caught");
17961796
}, onError:function ($e) {
1797-
if ($e instanceof Exception) {
1798-
$this->assertInstanceOf(Exception::class, $e);
1799-
$this->assertEquals("Error thrown to test update doesn't stopped and error is caught", $e->getMessage());
1800-
} else {
1801-
$this->fail("Caught value is not an Exception.");
1802-
}
1797+
$this->assertInstanceOf(Exception::class, $e);
1798+
$this->assertEquals("Error thrown to test update doesn't stopped and error is caught", $e->getMessage());
18031799
});
18041800

18051801
$document = $this->getDatabase()->findOne('testUpdateDocumentsRelationships1');
@@ -1841,25 +1837,17 @@ public function testUpdateDocumentsRelationships(): void
18411837
]), onNext: function () {
18421838
throw new Exception("Error thrown to test update doesn't stopped and error is caught");
18431839
}, onError:function ($e) {
1844-
if ($e instanceof Exception) {
1845-
$this->assertInstanceOf(Exception::class, $e);
1846-
$this->assertEquals("Error thrown to test update doesn't stopped and error is caught", $e->getMessage());
1847-
} else {
1848-
$this->fail("Caught value is not an Exception.");
1849-
}
1840+
$this->assertInstanceOf(Exception::class, $e);
1841+
$this->assertEquals("Error thrown to test update doesn't stopped and error is caught", $e->getMessage());
18501842
});
18511843

18521844
$this->getDatabase()->updateDocuments('testUpdateDocumentsRelationships2', new Document([
18531845
'testUpdateDocumentsRelationships1' => 'doc1'
18541846
]), onNext: function () {
18551847
throw new Exception("Error thrown to test update doesn't stopped and error is caught");
18561848
}, onError:function ($e) {
1857-
if ($e instanceof Exception) {
1858-
$this->assertInstanceOf(Exception::class, $e);
1859-
$this->assertEquals("Error thrown to test update doesn't stopped and error is caught", $e->getMessage());
1860-
} else {
1861-
$this->fail("Caught value is not an Exception.");
1862-
}
1849+
$this->assertInstanceOf(Exception::class, $e);
1850+
$this->assertEquals("Error thrown to test update doesn't stopped and error is caught", $e->getMessage());
18631851
});
18641852

18651853
$documents = $this->getDatabase()->find('testUpdateDocumentsRelationships2');

0 commit comments

Comments
 (0)