From 4790bbf07fb504806ec54af6d02224111ee4b8c5 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Wed, 24 Apr 2024 10:28:57 -0300 Subject: [PATCH] Add code coverage attributes --- .gitignore | 1 + phpunit.xml | 23 +++++++++++++++++++ tests/Channel/PearChannelTest.php | 2 ++ tests/Channel/PeclChannelTest.php | 2 ++ tests/ClientTest.php | 2 ++ tests/Resource/CategoryListTest.php | 2 ++ tests/Resource/Feed/CategoryFeedTest.php | 2 ++ tests/Resource/Feed/PackageFeedTest.php | 2 ++ tests/Resource/Package/InfoTest.php | 1 + tests/Resource/Package/Release/InfoTest.php | 2 ++ .../Resource/Package/Release/ManifestTest.php | 2 ++ .../Resource/Package/Release/VersionTest.php | 2 ++ tests/Resource/Package/ReleaseListTest.php | 2 ++ tests/Resource/Package/ReleaseTest.php | 2 ++ tests/Resource/PackageListTest.php | 2 ++ tests/Resource/PackageTest.php | 2 ++ tests/Traits/HttpRequestTest.php | 2 ++ 17 files changed, 53 insertions(+) create mode 100644 phpunit.xml diff --git a/.gitignore b/.gitignore index dd55f33..cb88e73 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.phpunit.cache composer.phar /vendor/ diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..44d1b7d --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,23 @@ + + + + + tests + + + + + + src + + + diff --git a/tests/Channel/PearChannelTest.php b/tests/Channel/PearChannelTest.php index fbb45a3..fb060db 100644 --- a/tests/Channel/PearChannelTest.php +++ b/tests/Channel/PearChannelTest.php @@ -3,10 +3,12 @@ namespace Pickling\Test\Channel; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Pickling\Channel\ChannelInterface; use Pickling\Channel\PearChannel; +#[CoversClass(PearChannel::class)] final class PearChannelTest extends TestCase { public function testGetUrl(): void { $pear = new PearChannel(); diff --git a/tests/Channel/PeclChannelTest.php b/tests/Channel/PeclChannelTest.php index 9a42583..f00b8b8 100644 --- a/tests/Channel/PeclChannelTest.php +++ b/tests/Channel/PeclChannelTest.php @@ -3,10 +3,12 @@ namespace Pickling\Test\Channel; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Pickling\Channel\ChannelInterface; use Pickling\Channel\PeclChannel; +#[CoversClass(PeclChannel::class)] final class PeclChannelTest extends TestCase { public function testGetUrl(): void { $pecl = new PeclChannel(); diff --git a/tests/ClientTest.php b/tests/ClientTest.php index f79325f..aab3eb0 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -4,6 +4,7 @@ namespace Pickling\Test; use Nyholm\Psr7\Factory\Psr17Factory; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Pickling\Channel\PeclChannel; use Pickling\Client; @@ -13,6 +14,7 @@ use Psr\Http\Message\ResponseInterface; use PsrMock\Psr18\Client as MockClient; +#[CoversClass(Client::class)] final class ClientTest extends TestCase { private MockClient $httpClient; private Psr17Factory $psr17Factory; diff --git a/tests/Resource/CategoryListTest.php b/tests/Resource/CategoryListTest.php index 1736563..f1c9366 100644 --- a/tests/Resource/CategoryListTest.php +++ b/tests/Resource/CategoryListTest.php @@ -3,10 +3,12 @@ namespace Pickling\Test\Resource; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Pickling\Resource\CategoryList; use SimpleXMLElement; +#[CoversClass(CategoryList::class)] final class CategoryListTest extends TestCase { public function testPropertyGetters(): void { $content = file_get_contents(__DIR__ . '/../Fixtures/categories.xml'); diff --git a/tests/Resource/Feed/CategoryFeedTest.php b/tests/Resource/Feed/CategoryFeedTest.php index e753423..e428834 100644 --- a/tests/Resource/Feed/CategoryFeedTest.php +++ b/tests/Resource/Feed/CategoryFeedTest.php @@ -3,12 +3,14 @@ namespace Pickling\Test\Resource\Feed; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Pickling\Resource\Feed\Category; use Pickling\Resource\Feed\Item; use SimpleXMLElement; +#[CoversClass(Category::class)] final class CategoryFeedTest extends TestCase { #[DataProvider('propertyGettersDataProvider')] public function testPropertyGetters(string $file, array $properties): void { diff --git a/tests/Resource/Feed/PackageFeedTest.php b/tests/Resource/Feed/PackageFeedTest.php index 3b90f05..c1860be 100644 --- a/tests/Resource/Feed/PackageFeedTest.php +++ b/tests/Resource/Feed/PackageFeedTest.php @@ -3,12 +3,14 @@ namespace Pickling\Test\Resource\Feed; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Pickling\Resource\Feed\Item; use Pickling\Resource\Feed\Package; use SimpleXMLElement; +#[CoversClass(Package::class)] final class PackageFeedTest extends TestCase { #[DataProvider('propertyGettersDataProvider')] public function testPropertyGetters(string $file, array $properties): void { diff --git a/tests/Resource/Package/InfoTest.php b/tests/Resource/Package/InfoTest.php index af70591..e98bd0f 100644 --- a/tests/Resource/Package/InfoTest.php +++ b/tests/Resource/Package/InfoTest.php @@ -8,6 +8,7 @@ use Pickling\Resource\Package\Info; use SimpleXMLElement; +#[CoversClass(Info::class)] final class InfoTest extends TestCase { #[DataProvider('propertyGettersDataProvider')] public function testPropertyGetters(string $file, array $properties): void { diff --git a/tests/Resource/Package/Release/InfoTest.php b/tests/Resource/Package/Release/InfoTest.php index 47c6bff..86e9a70 100644 --- a/tests/Resource/Package/Release/InfoTest.php +++ b/tests/Resource/Package/Release/InfoTest.php @@ -3,11 +3,13 @@ namespace Pickling\Test\Resource\Package\Release; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Pickling\Resource\Package\Release\Info; use SimpleXMLElement; +#[CoversClass(Info::class)] final class InfoTest extends TestCase { #[DataProvider('propertyGettersDataProvider')] public function testPropertyGetters(string $file, array $properties): void { diff --git a/tests/Resource/Package/Release/ManifestTest.php b/tests/Resource/Package/Release/ManifestTest.php index 092718f..478da7a 100644 --- a/tests/Resource/Package/Release/ManifestTest.php +++ b/tests/Resource/Package/Release/ManifestTest.php @@ -3,11 +3,13 @@ namespace Pickling\Test\Resource\Package\Release; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Pickling\Resource\Package\Release\Manifest; use SimpleXMLElement; +#[CoversClass(Manifest::class)] final class ManifestTest extends TestCase { #[DataProvider('propertyGettersDataProvider')] public function testPropertyGetters(string $file, array $properties): void { diff --git a/tests/Resource/Package/Release/VersionTest.php b/tests/Resource/Package/Release/VersionTest.php index 5e81c60..daa21ff 100644 --- a/tests/Resource/Package/Release/VersionTest.php +++ b/tests/Resource/Package/Release/VersionTest.php @@ -3,10 +3,12 @@ namespace Pickling\Test\Resource\Package\Release; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Pickling\Resource\Package\Release\Version; use SimpleXMLElement; +#[CoversClass(Version::class)] final class VersionTest extends TestCase { public function testPropertyGetters(): void { $version = new Version( diff --git a/tests/Resource/Package/ReleaseListTest.php b/tests/Resource/Package/ReleaseListTest.php index a337686..b5905c0 100644 --- a/tests/Resource/Package/ReleaseListTest.php +++ b/tests/Resource/Package/ReleaseListTest.php @@ -3,12 +3,14 @@ namespace Pickling\Test\Resource\Package; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Pickling\Resource\Package\Release\Version; use Pickling\Resource\Package\ReleaseList; use SimpleXMLElement; +#[CoversClass(ReleaseList::class)] final class ReleaseListTest extends TestCase { #[DataProvider('propertyGettersDataProvider')] public function testPropertyGetters(string $file, array $properties): void { diff --git a/tests/Resource/Package/ReleaseTest.php b/tests/Resource/Package/ReleaseTest.php index 9a5dd50..751dcbf 100644 --- a/tests/Resource/Package/ReleaseTest.php +++ b/tests/Resource/Package/ReleaseTest.php @@ -4,6 +4,7 @@ namespace Pickling\Test\Resource\Package; use Nyholm\Psr7\Factory\Psr17Factory; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Pickling\Channel\PeclChannel; use Pickling\Resource\Package\Release; @@ -12,6 +13,7 @@ use Psr\Http\Message\ResponseInterface; use PsrMock\Psr18\Client as MockClient; +#[CoversClass(Release::class)] final class ReleaseTest extends TestCase { private MockClient $httpClient; private Psr17Factory $psr17Factory; diff --git a/tests/Resource/PackageListTest.php b/tests/Resource/PackageListTest.php index 70f57d7..580ff02 100644 --- a/tests/Resource/PackageListTest.php +++ b/tests/Resource/PackageListTest.php @@ -3,10 +3,12 @@ namespace Pickling\Test\Resource; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Pickling\Resource\PackageList; use SimpleXMLElement; +#[CoversClass(PackageList::class)] final class PackageListTest extends TestCase { public function testPropertyGetters(): void { $content = file_get_contents(__DIR__ . '/../Fixtures/packages.xml'); diff --git a/tests/Resource/PackageTest.php b/tests/Resource/PackageTest.php index ce5ed18..ea0f53b 100644 --- a/tests/Resource/PackageTest.php +++ b/tests/Resource/PackageTest.php @@ -4,6 +4,7 @@ namespace Pickling\Test\Resource; use Nyholm\Psr7\Factory\Psr17Factory; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Pickling\Channel\PeclChannel; use Pickling\Resource\Package; @@ -13,6 +14,7 @@ use Psr\Http\Message\ResponseInterface; use PsrMock\Psr18\Client as MockClient; +#[CoversClass(Package::class)] final class PackageTest extends TestCase { private MockClient $httpClient; private Psr17Factory $psr17Factory; diff --git a/tests/Traits/HttpRequestTest.php b/tests/Traits/HttpRequestTest.php index 8a5e768..bd44a72 100644 --- a/tests/Traits/HttpRequestTest.php +++ b/tests/Traits/HttpRequestTest.php @@ -4,6 +4,7 @@ namespace Pickling\Test\Traits; use Nyholm\Psr7\Factory\Psr17Factory; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Pickling\Traits\HttpRequest; use Psr\Http\Client\ClientInterface; @@ -14,6 +15,7 @@ use RuntimeException; use stdClass; +#[CoversClass(HttpRequest::class)] final class HttpRequestTest extends TestCase { private MockClient $httpClient; private Psr17Factory $psr17Factory;