1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-05-08 07:55:20 +02:00

Improve assertion and ignore cached PHPUnit file (#462)

This commit is contained in:
Chun-Sheng, Li 2024-03-30 14:26:17 +08:00 committed by GitHub
parent e903b29e17
commit 6706ad4d2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 10 deletions

View File

@ -19,7 +19,7 @@ class AggregatedCollectorTest extends DebugBarTestCase
$this->c->addCollector($c = new MockCollector()); $this->c->addCollector($c = new MockCollector());
$this->assertContains($c, $this->c->getCollectors()); $this->assertContains($c, $this->c->getCollectors());
$this->assertEquals($c, $this->c['mock']); $this->assertEquals($c, $this->c['mock']);
$this->assertTrue(isset($this->c['mock'])); $this->assertArrayHasKey('mock', $this->c);
} }
public function testCollect() public function testCollect()

View File

@ -37,7 +37,7 @@ class TimeDataCollectorTest extends DebugBarTestCase
$this->assertEquals('bar', $m[0]['label']); $this->assertEquals('bar', $m[0]['label']);
$this->assertEquals('baz', $m[0]['collector']); $this->assertEquals('baz', $m[0]['collector']);
$this->assertEquals(array('bar' => 'baz'), $m[0]['params']); $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() public function testCollect()
@ -45,8 +45,8 @@ class TimeDataCollectorTest extends DebugBarTestCase
$this->c->addMeasure('foo', 0, 10); $this->c->addMeasure('foo', 0, 10);
$this->c->addMeasure('bar', 10, 20); $this->c->addMeasure('bar', 10, 20);
$data = $this->c->collect(); $data = $this->c->collect();
$this->assertTrue($data['end'] > $this->s); $this->assertGreaterThan($this->s, $data['end']);
$this->assertTrue($data['duration'] > 0); $this->assertGreaterThan(0, $data['duration']);
$this->assertCount(2, $data['measures']); $this->assertCount(2, $data['measures']);
} }
@ -59,7 +59,7 @@ class TimeDataCollectorTest extends DebugBarTestCase
$m = $this->c->getMeasures(); $m = $this->c->getMeasures();
$this->assertCount(1, $m); $this->assertCount(1, $m);
$this->assertEquals('bar', $m[0]['label']); $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); $this->assertSame('returnedValue', $returned);
} }
} }

View File

@ -42,8 +42,8 @@ class DebugBarTest extends DebugBarTestCase
{ {
$this->debugbar->addCollector($c = new MockCollector()); $this->debugbar->addCollector($c = new MockCollector());
$this->assertEquals($c, $this->debugbar['mock']); $this->assertEquals($c, $this->debugbar['mock']);
$this->assertTrue(isset($this->debugbar['mock'])); $this->assertArrayHasKey('mock', $this->debugbar);
$this->assertFalse(isset($this->debugbar['foo'])); $this->assertArrayNotHasKey('foo', $this->debugbar);
} }
public function testStorage() public function testStorage()
@ -96,7 +96,7 @@ class DebugBarTest extends DebugBarTestCase
$data = $this->debugbar->getStackedData(); $data = $this->debugbar->getStackedData();
$this->assertArrayNotHasKey($ns, $http->session); $this->assertArrayNotHasKey($ns, $http->session);
$this->assertArrayHasKey($id, $data); $this->assertArrayHasKey($id, $data);
$this->assertEquals(1, count($data)); $this->assertCount(1, $data);
$this->assertArrayHasKey('mock', $data[$id]); $this->assertArrayHasKey('mock', $data[$id]);
$this->assertEquals($c->collect(), $data[$id]['mock']); $this->assertEquals($c->collect(), $data[$id]['mock']);
} }

View File

@ -19,13 +19,13 @@ abstract class DebugBarTestCase extends TestCase
public function assertJsonIsArray($json) public function assertJsonIsArray($json)
{ {
$data = json_decode($json); $data = json_decode($json);
$this->assertTrue(is_array($data)); $this->assertIsArray($data);
} }
public function assertJsonIsObject($json) public function assertJsonIsObject($json)
{ {
$data = json_decode($json); $data = json_decode($json);
$this->assertTrue(is_object($data)); $this->assertIsObject($data);
} }
public function assertJsonArrayNotEmpty($json) public function assertJsonArrayNotEmpty($json)