From c37a0438424cb494a1831f2fd3cef8981a949f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20K=C3=A4hm?= Date: Thu, 26 Oct 2023 23:33:24 +0200 Subject: [PATCH] [BUGFIX] Fix value precision for unit tests --- .github/workflows/ci.yml | 2 +- .gitignore | 3 +- Build/Test/phpunit.xml | 46 +++++++++---------- Tests/Domain/AbstractSolrTestCase.php | 3 +- .../Explanation/ExplainServiceTestCase.php | 10 ++-- .../Explanation/ExplanationSolr3TestCase.php | 6 +-- .../SummarizeFieldImpactsTestCase.php | 2 +- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6020e96..2c83202 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.gitignore b/.gitignore index 6667882..3617471 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .buildpath .project .settings/ -.Build \ No newline at end of file +.Build +composer.lock diff --git a/Build/Test/phpunit.xml b/Build/Test/phpunit.xml index 7ace0f9..15f5020 100644 --- a/Build/Test/phpunit.xml +++ b/Build/Test/phpunit.xml @@ -1,27 +1,27 @@ - - - ../../Classes/ - - - - - ../../Tests/ - - + + + ../../Classes/ + + + + + ../../Tests/ + + diff --git a/Tests/Domain/AbstractSolrTestCase.php b/Tests/Domain/AbstractSolrTestCase.php index 19cdebf..031b635 100644 --- a/Tests/Domain/AbstractSolrTestCase.php +++ b/Tests/Domain/AbstractSolrTestCase.php @@ -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. * @@ -31,4 +30,4 @@ protected function getFixtureContent($fixtureFilename) return file_get_contents($this->getTestFixturePath().$fixtureFilename); } -} \ No newline at end of file +} diff --git a/Tests/Domain/Result/Explanation/ExplainServiceTestCase.php b/Tests/Domain/Result/Explanation/ExplainServiceTestCase.php index 6acbae0..e70da97 100644 --- a/Tests/Domain/Result/Explanation/ExplainServiceTestCase.php +++ b/Tests/Domain/Result/Explanation/ExplainServiceTestCase.php @@ -48,7 +48,7 @@ public function testCanNotCreateEmptyNodes() /** * @test */ - public function testCanParseSynonymeNodes() + public function testCanParseSynonymNodes() { $content = $this->getFixtureContent('6.6.001.txt'); $result = ExplainService::getFieldImpactsFromRawContent( @@ -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); diff --git a/Tests/Domain/Result/Explanation/ExplanationSolr3TestCase.php b/Tests/Domain/Result/Explanation/ExplanationSolr3TestCase.php index dc78d0a..a0730be 100644 --- a/Tests/Domain/Result/Explanation/ExplanationSolr3TestCase.php +++ b/Tests/Domain/Result/Explanation/ExplanationSolr3TestCase.php @@ -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()); } @@ -108,4 +108,4 @@ public function testFixture005() $this->assertEquals(5.8746934,$explain->getRootNode()->getScore()); $this->assertEquals(2, $explain->getChildren()->count()); } -} \ No newline at end of file +} diff --git a/Tests/Domain/Result/Explanation/Visitors/SummarizeFieldImpactsTestCase.php b/Tests/Domain/Result/Explanation/Visitors/SummarizeFieldImpactsTestCase.php index 7f2c9e0..c43a3f4 100644 --- a/Tests/Domain/Result/Explanation/Visitors/SummarizeFieldImpactsTestCase.php +++ b/Tests/Domain/Result/Explanation/Visitors/SummarizeFieldImpactsTestCase.php @@ -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()); }