Skip to content

Commit 339b8a2

Browse files
authored
Remove early returns for failed tests from tearDown methods (#1071)
1 parent 7dcdf8b commit 339b8a2

File tree

5 files changed

+11
-21
lines changed

5 files changed

+11
-21
lines changed

tests/Collection/FunctionalTestCase.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ public function setUp(): void
2424

2525
public function tearDown(): void
2626
{
27-
if ($this->hasFailed()) {
28-
return;
27+
if (! $this->hasFailed()) {
28+
$this->dropCollection();
2929
}
3030

31-
$this->dropCollection();
32-
3331
parent::tearDown();
3432
}
3533
}

tests/DocumentationExamplesTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ public function setUp(): void
4040

4141
public function tearDown(): void
4242
{
43-
if ($this->hasFailed()) {
44-
return;
43+
if (! $this->hasFailed()) {
44+
$this->dropCollection();
4545
}
4646

47-
$this->dropCollection();
48-
4947
parent::tearDown();
5048
}
5149

tests/Model/IndexInfoFunctionalTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ public function setUp(): void
2020

2121
public function tearDown(): void
2222
{
23-
if ($this->hasFailed()) {
24-
return;
23+
if (! $this->hasFailed()) {
24+
$this->collection->drop();
2525
}
2626

27-
$this->collection->drop();
28-
2927
parent::tearDown();
3028
}
3129

tests/Operation/FunctionalTestCase.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ public function setUp(): void
2020

2121
public function tearDown(): void
2222
{
23-
if ($this->hasFailed()) {
24-
return;
23+
if (! $this->hasFailed()) {
24+
$this->dropCollection();
2525
}
2626

27-
$this->dropCollection();
28-
2927
parent::tearDown();
3028
}
3129

tests/Operation/RenameCollectionFunctionalTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ public function setUp(): void
3131

3232
public function tearDown(): void
3333
{
34-
if ($this->hasFailed()) {
35-
return;
34+
if (! $this->hasFailed()) {
35+
$operation = new DropCollection($this->getDatabaseName(), $this->toCollectionName);
36+
$operation->execute($this->getPrimaryServer());
3637
}
3738

38-
$operation = new DropCollection($this->getDatabaseName(), $this->toCollectionName);
39-
$operation->execute($this->getPrimaryServer());
40-
4139
parent::tearDown();
4240
}
4341

0 commit comments

Comments
 (0)