Skip to content

Commit

Permalink
Update tests: Use assertArrayNotHasKey() instead of expectError() bef…
Browse files Browse the repository at this point in the history
…ore accessing the key
  • Loading branch information
pavog committed Sep 11, 2024
1 parent d85fbaa commit d238bdd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
6 changes: 2 additions & 4 deletions test/tests/Analysis/AnalysisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ public function testOffsetGet(): void
$this->assertEquals($information, $analysis[0]);

// Does not exist -> "undefined array key" error
$this->expectError();
$this->assertEquals(null, $analysis[1]);
$this->assertArrayNotHasKey(1, $analysis);
}

public function testOffsetSet(): void
Expand Down Expand Up @@ -153,7 +152,6 @@ public function testOffsetUnset(): void
// Unset $information on $analysis[0] using the offsetUnset
unset($analysis[0]);
$this->assertArrayNotHasKey(0, $analysis);
$this->expectError();
$this->assertEquals(null, $analysis[1]);
$this->assertArrayNotHasKey(1, $analysis);
}
}
6 changes: 2 additions & 4 deletions test/tests/Analysis/ProblemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public function testOffsetGet(): void
$this->assertEquals($solution, $problem[0]);

// Does not exist -> "undefined array key" error
$this->expectError();
$this->assertEquals(null, $problem[1]);
$this->assertArrayNotHasKey(1, $problem);
}

public function testOffsetSet(): void
Expand Down Expand Up @@ -109,7 +108,6 @@ public function testOffsetUnset(): void
// Unset $solution on $problem[0] using the offsetUnset
unset($problem[0]);
$this->assertArrayNotHasKey(0, $problem);
$this->expectError();
$this->assertEquals(null, $problem[1]);
$this->assertArrayNotHasKey(1, $problem);
}
}
6 changes: 2 additions & 4 deletions test/tests/Log/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public function testOffsetGet(): void
$this->assertEquals($line, $entry[0]);

// Does not exist -> "undefined array key" error
$this->expectError();
$this->assertEquals(null, $entry[1]);
$this->assertArrayNotHasKey(1, $entry);
}

public function testOffsetSet(): void
Expand Down Expand Up @@ -126,7 +125,6 @@ public function testOffsetUnset(): void
// Unset $line1 on $entry[0] using the offsetUnset
unset($entry[0]);
$this->assertArrayNotHasKey(0, $entry);
$this->expectError();
$this->assertEquals(null, $entry[1]);
$this->assertArrayNotHasKey(1, $entry);
}
}
6 changes: 2 additions & 4 deletions test/tests/Log/LogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public function testOffsetGet(): void
$this->assertEquals($entry, $log[0]);

// Does not exist -> "undefined array key" error
$this->expectError();
$this->assertEquals(null, $log[1]);
$this->assertArrayNotHasKey(1, $log);
}

public function testOffsetSet(): void
Expand All @@ -99,7 +98,6 @@ public function testOffsetUnset(): void
// Unset $entry on $log[0] using the offsetUnset
unset($log[0]);
$this->assertArrayNotHasKey(0, $log);
$this->expectError();
$this->assertEquals(null, $log[1]);
$this->assertArrayNotHasKey(1, $log);
}
}

0 comments on commit d238bdd

Please sign in to comment.