Skip to content

Commit

Permalink
Improve assertion and ignore cached PHPUnit file (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Mar 30, 2024
1 parent e903b29 commit 6706ad4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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);
}

public function testCollect()
Expand Down
8 changes: 4 additions & 4 deletions tests/DebugBar/Tests/DataCollector/TimeDataCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,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']);
}

public function testCollect()
{
$this->c->addMeasure('foo', 0, 10);
$this->c->addMeasure('bar', 10, 20);
$data = $this->c->collect();
$this->assertTrue($data['end'] > $this->s);
$this->assertTrue($data['duration'] > 0);
$this->assertGreaterThan($this->s, $data['end']);
$this->assertGreaterThan(0, $data['duration']);
$this->assertCount(2, $data['measures']);
}

Expand All @@ -59,7 +59,7 @@ public function testMeasure()
$m = $this->c->getMeasures();
$this->assertCount(1, $m);
$this->assertEquals('bar', $m[0]['label']);
$this->assertTrue($m[0]['start'] < $m[0]['end']);
$this->assertLessThan($m[0]['end'], $m[0]['start']);
$this->assertSame('returnedValue', $returned);
}
}
6 changes: 3 additions & 3 deletions tests/DebugBar/Tests/DebugBarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public function testArrayAccess()
{
$this->debugbar->addCollector($c = new MockCollector());
$this->assertEquals($c, $this->debugbar['mock']);
$this->assertTrue(isset($this->debugbar['mock']));
$this->assertFalse(isset($this->debugbar['foo']));
$this->assertArrayHasKey('mock', $this->debugbar);
$this->assertArrayNotHasKey('foo', $this->debugbar);
}

public function testStorage()
Expand Down Expand Up @@ -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);
$this->assertArrayHasKey('mock', $data[$id]);
$this->assertEquals($c->collect(), $data[$id]['mock']);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/DebugBar/Tests/DebugBarTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public function setUp(): void
public function assertJsonIsArray($json)
{
$data = json_decode($json);
$this->assertTrue(is_array($data));
$this->assertIsArray($data);
}

public function assertJsonIsObject($json)
{
$data = json_decode($json);
$this->assertTrue(is_object($data));
$this->assertIsObject($data);
}

public function assertJsonArrayNotEmpty($json)
Expand Down

0 comments on commit 6706ad4

Please sign in to comment.