Skip to content

Commit 0702b85

Browse files
committed
fix: phpunit
1 parent bc5916c commit 0702b85

5 files changed

+20
-14
lines changed

phpunit.xml.dist

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
33
<coverage>
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
74
<report>
85
<clover outputFile="build/logs/clover.xml"/>
96
<html outputDirectory="build/coverage" lowUpperBound="35" highLowerBound="70"/>
@@ -18,4 +15,9 @@
1815
<logging>
1916
<junit outputFile="build/report.junit.xml"/>
2017
</logging>
18+
<source>
19+
<include>
20+
<directory suffix=".php">src/</directory>
21+
</include>
22+
</source>
2123
</phpunit>

tests/BarcodeFindTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@
33
namespace OpenFoodFacts\Laravel\Tests;
44

55
use OpenFoodFacts\Laravel\Facades\OpenFoodFacts;
6+
use PHPUnit\Framework\Attributes\Test;
67

78
class BarcodeFindTest extends Base\FacadeTestCase
89
{
9-
/** @test */
10+
#[Test]
1011
public function it_returns_an_array_with_data_when_product_found(): void
1112
{
1213
$arr = OpenFoodFacts::barcode('0737628064502');
1314
$this->assertArrayHasKey('code', $arr);
1415
}
1516

16-
/** @test */
17+
#[Test]
1718
public function it_returns_an_empty_array_when_product_not_found(): void
1819
{
1920
$arr = OpenFoodFacts::barcode('this-barcode-does-not-exist');
2021

2122
$this->assertEquals([], $arr);
2223
}
2324

24-
/** @test */
25+
#[Test]
2526
public function it_throws_an_exception_when_argument_empty(): void
2627
{
2728
$this->expectException('InvalidArgumentException');

tests/FacadeBridgeToApiTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
use OpenFoodFacts\Document;
66
use OpenFoodFacts\Laravel\Facades\OpenFoodFacts;
7+
use PHPUnit\Framework\Attributes\Test;
78

89
class FacadeBridgeToApiTest extends Base\FacadeTestCase
910
{
10-
/** @test */
11+
#[Test]
1112
public function it_calls_method_on_vendor_apiclass(): void
1213
{
1314
$doc = OpenFoodFacts::getProduct('0737628064502');

tests/GeographyTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
use Illuminate\Support\Facades\Config;
66
use OpenFoodFacts\Laravel\Facades\OpenFoodFacts as OpenFoodFactsFacade;
77
use OpenFoodFacts\Laravel\OpenFoodFacts;
8+
use PHPUnit\Framework\Attributes\Test;
89

910
class GeographyTest extends Base\FacadeTestCase
1011
{
11-
/** @test */
12+
#[Test]
1213
public function it_returns_different_content_based_on_geography_parameter(): void
1314
{
1415
$barcode = '8714200216964';
@@ -23,7 +24,7 @@ public function it_returns_different_content_based_on_geography_parameter(): voi
2324
$this->assertNotEquals($product_default_content, $product_dutch_content);
2425
}
2526

26-
/** @test */
27+
#[Test]
2728
public function it_returns_geo_specific_content_through_config_setting(): void
2829
{
2930
Config::set('openfoodfacts.geography', 'nl');

tests/ProductSearchTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace OpenFoodFacts\Laravel\Tests;
44

55
use OpenFoodFacts\Laravel\Facades\OpenFoodFacts;
6+
use PHPUnit\Framework\Attributes\Test;
67

78
class ProductSearchTest extends Base\FacadeTestCase
89
{
9-
/** @test */
10+
#[Test]
1011
public function it_returns_a_laravelcollection_with_arrays(): void
1112
{
1213
$results = OpenFoodFacts::find('Stir-Fry Rice Noodles');
@@ -20,7 +21,7 @@ public function it_returns_a_laravelcollection_with_arrays(): void
2021
});
2122
}
2223

23-
/** @test */
24+
#[Test]
2425
public function it_returns_an_empty_laravelcollection_when_no_results_found(): void
2526
{
2627
$results = OpenFoodFacts::find('no-such-product-exists');
@@ -30,15 +31,15 @@ public function it_returns_an_empty_laravelcollection_when_no_results_found(): v
3031
$this->assertEquals(true, $results->isEmpty());
3132
}
3233

33-
/** @test */
34+
#[Test]
3435
public function it_throws_an_exception_on_too_many_results(): void
3536
{
3637
$this->expectException('Exception');
3738

3839
OpenFoodFacts::find('cola');
3940
}
4041

41-
/** @test */
42+
#[Test]
4243
public function it_throws_an_exception_when_argument_empty(): void
4344
{
4445
$this->expectException('InvalidArgumentException');

0 commit comments

Comments
 (0)