Skip to content

Commit

Permalink
[BUGFIX] Fix value precision for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dkd-kaehm committed Oct 26, 2023
1 parent ea11b5b commit d0f6ed0
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.PHP }}
coverage: xdebug
coverage: pcov
tools: composer:v2

- name: CI-Bootstrap
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.Build
.buildpath
.project
.settings/
.Build
composer.lock
46 changes: 23 additions & 23 deletions Build/Test/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="../../.Build/vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="true"
stopOnFailure="true"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
bootstrap="../../.Build/vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
>
<coverage processUncoveredFiles="false">
<include>
<directory suffix=".php">../../Classes/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="php-solr-explain-unit-tests">
<directory suffix="TestCase.php">../../Tests/</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="false">
<include>
<directory suffix=".php">../../Classes/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="php-solr-explain-unit-tests">
<directory suffix="TestCase.php">../../Tests/</directory>
</testsuite>
</testsuites>
</phpunit>
3 changes: 1 addition & 2 deletions Tests/Domain/AbstractSolrTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

abstract class AbstractSolrTest extends TestCase
{

/**
* Helper method to get the path of a "fixtures" folder that is relative to the current class folder.
*
Expand All @@ -31,4 +30,4 @@ protected function getFixtureContent($fixtureFilename)
return file_get_contents($this->getTestFixturePath().$fixtureFilename);
}

}
}
10 changes: 5 additions & 5 deletions Tests/Domain/Result/Explanation/ExplainServiceTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testCanNotCreateEmptyNodes()
/**
* @test
*/
public function testCanParseSynonymeNodes()
public function testCanParseSynonymNodes()
{
$content = $this->getFixtureContent('6.6.001.txt');
$result = ExplainService::getFieldImpactsFromRawContent(
Expand All @@ -58,10 +58,10 @@ public function testCanParseSynonymeNodes()
);

$expectedResult = [
'keywords' => 8.2394580648419,
'description' => 2.1925963619964,
'tagsH1' => 8.539163146877,
'content' => 81.028780249768
'keywords' => 8.239458064841905,
'description' => 2.1925963619964572,
'tagsH1' => 8.539163146876982,
'content' => 81.02878024976832,
];

$this->assertEquals($expectedResult, $result);
Expand Down
6 changes: 3 additions & 3 deletions Tests/Domain/Result/Explanation/ExplanationSolr3TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public function testFixture001GetImpact()
// 0.5044475 * 73,582959599 = 37,118740012 / 2 => 18,559370006
// 0.8545628 * 73,582959599 = 62,881259988 / 2 => 31,440629994

$this->assertEquals(18.559370006246,$explain->getRootNode()->getChild(0)->getChild(0)->getChild(0)->getChild(0)->getAbsoluteImpactPercentage());
$this->assertEquals(31.440629993754,$explain->getRootNode()->getChild(0)->getChild(0)->getChild(0)->getChild(1)->getAbsoluteImpactPercentage());
$this->assertEquals(18.55937000624646,$explain->getRootNode()->getChild(0)->getChild(0)->getChild(0)->getChild(0)->getAbsoluteImpactPercentage());
$this->assertEquals(31.440629993753543,$explain->getRootNode()->getChild(0)->getChild(0)->getChild(0)->getChild(1)->getAbsoluteImpactPercentage());
$this->assertEquals(Explain::NODE_TYPE_MAX,$explain->getRootNode()->getChild(0)->getChild(0)->getNodeType());
}

Expand Down Expand Up @@ -108,4 +108,4 @@ public function testFixture005()
$this->assertEquals(5.8746934,$explain->getRootNode()->getScore());
$this->assertEquals(2, $explain->getChildren()->count());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testCanSummarizeFieldImpactFixture003()
$visitor = new SummarizeFieldImpacts();
$explain->getRootNode()->visitNodes($visitor);

$this->assertEquals(95.756597168764,$visitor->getFieldImpact('price'));
$this->assertEquals(95.75659716876356,$visitor->getFieldImpact('price'));
$this->assertEquals(['name','manu','price'],$visitor->getRelevantFieldNames());
}

Expand Down

0 comments on commit d0f6ed0

Please sign in to comment.