New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve assertion and ignore cached PHPUnit file #462
Improve assertion and ignore cached PHPUnit file #462
Conversation
@@ -17,7 +17,7 @@ public function testAddCollector() | |||
$this->c->addCollector($c = new MockCollector()); | |||
$this->assertContains($c, $this->c->getCollectors()); | |||
$this->assertEquals($c, $this->c['mock']); | |||
$this->assertTrue(isset($this->c['mock'])); | |||
$this->assertArrayHasKey('mock', $this->c); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the assertArrayHasKey
to assert the expected key is on the result array.
@@ -33,16 +33,16 @@ public function testStartStopMeasure() | |||
$this->assertEquals('bar', $m[0]['label']); | |||
$this->assertEquals('baz', $m[0]['collector']); | |||
$this->assertEquals(array('bar' => 'baz'), $m[0]['params']); | |||
$this->assertTrue($m[0]['start'] < $m[0]['end']); | |||
$this->assertLessThan($m[0]['end'], $m[0]['start']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the assertLessThan
to assert expected and result comparison.
$this->assertTrue($data['end'] > $this->s); | ||
$this->assertTrue($data['duration'] > 0); | ||
$this->assertGreaterThan($this->s, $data['end']); | ||
$this->assertGreaterThan(0, $data['duration']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the assertGreaterThan
to assert expected and result comparison.
@@ -96,7 +96,7 @@ public function testStackedData() | |||
$data = $this->debugbar->getStackedData(); | |||
$this->assertArrayNotHasKey($ns, $http->session); | |||
$this->assertArrayHasKey($id, $data); | |||
$this->assertEquals(1, count($data)); | |||
$this->assertCount(1, $data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the assertCount
to assert expected is same as result count.
@@ -17,13 +17,13 @@ public function setUp(): void | |||
public function assertJsonIsArray($json) | |||
{ | |||
$data = json_decode($json); | |||
$this->assertTrue(is_array($data)); | |||
$this->assertIsArray($data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the assertIsArray
to assert expected type is array
type.
} | ||
|
||
public function assertJsonIsObject($json) | ||
{ | ||
$data = json_decode($json); | ||
$this->assertTrue(is_object($data)); | ||
$this->assertIsObject($data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the assertIsObject
to assert expected type is object
.
167eb0e
to
847dd04
Compare
Changed log
.phpunit.result.cache
file be on.gitignore
file and this is generated byPHPUnit 9.x.
version.