Skip to content

Commit

Permalink
Update coverage reports
Browse files Browse the repository at this point in the history
  • Loading branch information
benpoulson committed Jan 10, 2024
1 parent 67c119f commit bcf0c1f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
vendor/
workbench/
.phpunit.result.cache
.phpunit.cache/
coverage.xml
29 changes: 20 additions & 9 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
stopOnFailure="true"
>
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="false"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="Unit">
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<php>
<const name="PHPUNIT_RUNNING" value="true"/>
</php>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
15 changes: 6 additions & 9 deletions src/BprofLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,15 @@ public function computeExclusiveMetrics(array $perfdata, array &$symbolTab, arra
}
}


/**
* Compute inclusive metrics for function. This code was factored out
* of bprof_compute_flat_info().
* Computes the inclusive times and call count for each function in the given performance data.
*
* The raw data contains inclusive metrics of a function for each
* unique parent function it is called from. The total inclusive metrics
* for a function is therefore the sum of inclusive metrics for the
* function across all parents.
* @param array $perfdata The performance data containing parent-child relationships and metrics.
*
* @return array The computed inclusive times and call count for each function.
* @throws RuntimeException If the parent and child are the same.
*
* @param array<string, array<string, numeric>> $perfdata bprof format raw profiler data.
* @return array<string, array<string, numeric>> Returns a map of function name to total (across all parents) inclusive metrics for the function.
* @covers BprofLib::computeInclusiveTimes
*/
public function computeInclusiveTimes(array $perfdata): array

Check failure on line 174 in src/BprofLib.php

View workflow job for this annotation

GitHub Actions / PHP 8.0

Method Nexelity\Bprof\BprofLib::computeInclusiveTimes() has parameter $perfdata with no value type specified in iterable type array.

Check failure on line 174 in src/BprofLib.php

View workflow job for this annotation

GitHub Actions / PHP 8.0

Method Nexelity\Bprof\BprofLib::computeInclusiveTimes() return type has no value type specified in iterable type array.
{
Expand Down
16 changes: 11 additions & 5 deletions tests/BprofLibTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Tests for BprofLib class.
* @coversDefaultClass \Nexelity\Bprof\BprofLib
*/
class BprofLibTest extends TestCase
{
Expand All @@ -24,7 +25,7 @@ protected function setUp(): void
/**
* Tests initMetrics method.
* Asserts if metrics are initialized properly, without any errors.
* @covers BprofLib::initMetrics
* @covers ::initMetrics
*/
public function testInitMetrics(): void
{
Expand Down Expand Up @@ -52,7 +53,7 @@ public function testInitMetrics(): void
/**
* Tests getPossibleMetrics methods.
* Asserts if method returns expected possible metrics.
* @covers BprofLib::getPossibleMetrics
* @covers ::getPossibleMetrics
*/
public function testGetPossibleMetrics(): void
{
Expand All @@ -71,7 +72,7 @@ public function testGetPossibleMetrics(): void
/**
* Test to confirm that the getMetrics method
* in BprofLib returns the correct metric array
* @covers BprofLib::getMetrics
* @covers ::getMetrics
*/
public function testGetMetrics(): void
{
Expand Down Expand Up @@ -106,7 +107,7 @@ public function testGetMetrics(): void
}

/**
* @covers BprofLib::parseParentChild
* @covers ::parseParentChild
*/
public function testParseParentChild(): void
{
Expand All @@ -122,7 +123,7 @@ public function testParseParentChild(): void
}

/**
* @covers BprofLib::computeFlatInfo
* @covers ::computeFlatInfo
*/
public function testComputeFlatInfo()
{
Expand Down Expand Up @@ -176,6 +177,7 @@ public function testComputeFlatInfo()
* 2. when a function call is part of the parent function but the parent function is not in the symbol table
* 3. when a function call is part of the parent function and the parent function is also in the symbol table
* 4. when a function call itself is the parent function
* @covers ::computeExclusiveMetrics
*/
public function testComputeExclusiveMetrics(): void
{
Expand Down Expand Up @@ -208,6 +210,10 @@ public function testComputeExclusiveMetrics(): void
}


/**
* @return void
* @covers ::computeInclusiveTimes
*/
public function testComputeInclusiveTimes(): void
{
$perfData = [
Expand Down
12 changes: 12 additions & 0 deletions tests/PerfDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ protected function setUp(): void
$this->cast = new PerfData();
}

/**
* @return void
* @covers \Nexelity\Bprof\Casts\PerfData::get
*/
#[Test]
public function testGet(): void
{
Expand All @@ -34,6 +38,10 @@ public function testGet(): void
$this->assertEquals(['foo' => 'bar'], $result);
}

/**
* @return void
* @covers \Nexelity\Bprof\Casts\PerfData::get
*/
#[Test]
public function testGetNullValue(): void
{
Expand All @@ -43,6 +51,10 @@ public function testGetNullValue(): void
$this->cast->get($trace, '', null, []);
}

/**
* @return void
* @covers \Nexelity\Bprof\Casts\PerfData::get
*/
#[Test]
public function testGetUnzippedFailure(): void
{
Expand Down

0 comments on commit bcf0c1f

Please sign in to comment.