From cfd9de6a032c3dcfe460df167b207d13c5446c45 Mon Sep 17 00:00:00 2001 From: Gareth Parker Date: Sat, 24 Aug 2024 12:38:54 +0100 Subject: [PATCH] Update dataProviders in the tests --- tests/src/API/ExchangeAutodiscoverTest.php | 8 ++------ tests/src/API/ExchangeWebServicesTest.php | 8 ++------ tests/src/API/TypeTest.php | 12 +++--------- tests/src/APITest.php | 17 +++-------------- tests/src/CasterTest.php | 17 +++-------------- 5 files changed, 13 insertions(+), 49 deletions(-) diff --git a/tests/src/API/ExchangeAutodiscoverTest.php b/tests/src/API/ExchangeAutodiscoverTest.php index db7efdd6..c05ceb92 100644 --- a/tests/src/API/ExchangeAutodiscoverTest.php +++ b/tests/src/API/ExchangeAutodiscoverTest.php @@ -7,6 +7,7 @@ use garethp\ews\API\ExchangeAutodiscover as Autodiscover; use garethp\ews\API\Exception\AutodiscoverFailed; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ExchangeAutodiscoverTest extends TestCase { @@ -67,12 +68,7 @@ public function testGetAPIFailure() $this->assertInstanceOf(API::class, $client); } - /** - * @dataProvider serverVersionProvider - * - * @param $hex - * @param $expectedVersion - */ + #[DataProvider('serverVersionProvider')] public function testParseServerVersion($hex, $expectedVersion) { $reflectedClass = new \ReflectionClass(Autodiscover::class); diff --git a/tests/src/API/ExchangeWebServicesTest.php b/tests/src/API/ExchangeWebServicesTest.php index e7d18040..e89f1fb8 100644 --- a/tests/src/API/ExchangeWebServicesTest.php +++ b/tests/src/API/ExchangeWebServicesTest.php @@ -12,6 +12,7 @@ use garethp\ews\API\Type; use Mockery; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ExchangeWebServicesTest extends TestCase { @@ -27,12 +28,7 @@ public function getClientMock() return $mock; } - /** - * - * @dataProvider cleanServerUrlProvider - * @param $input - * @param $expected - */ + #[DataProvider('cleanServerUrlProvider')] public function testCleanServerUrl($input, $expected) { $client = $this->getClientMock(); diff --git a/tests/src/API/TypeTest.php b/tests/src/API/TypeTest.php index d1565a62..1db2e321 100644 --- a/tests/src/API/TypeTest.php +++ b/tests/src/API/TypeTest.php @@ -8,6 +8,7 @@ use PHPUnit\Framework\TestCase; use Mockery; use DateTime; +use PHPUnit\Framework\Attributes\DataProvider; class TypeTest extends TestCase { @@ -72,12 +73,7 @@ public function testBuildFromArray() $this->assertEquals($calendarControl, $calendarItem); } - /** - * @dataProvider arrayAssocProvider - * - * @param $array - * @param $expected - */ + #[DataProvider('arrayAssocProvider')] public function testArrayIsAssoc($array, $expected) { $type = $this->getTypeMock(); @@ -86,9 +82,7 @@ public function testArrayIsAssoc($array, $expected) $this->assertEquals($expected, $isAssoc); } - /** - * @dataProvider toStringProvider - */ + #[DataProvider('toStringProvider')] public function testToString($string, $expected) { $type = $this->getTypeMock(); diff --git a/tests/src/APITest.php b/tests/src/APITest.php index 99388b24..47b2ca35 100644 --- a/tests/src/APITest.php +++ b/tests/src/APITest.php @@ -3,8 +3,7 @@ namespace garethp\ews\Test; use garethp\ews\API; -use garethp\ews\API\Type; -use Mockery; +use PHPUnit\Framework\Attributes\DataProvider; use garethp\ews\API\ExchangeWebServices; use garethp\ews\API\Enumeration; @@ -269,12 +268,7 @@ public function testDeleteItemsFail() $client->deleteItems($item->toArray(), ['SendMeetingCancellations' => 'SendToNone']); } - /** - * @dataProvider getFolderByDisplayNameProvider - * - * @param $input - * @param $expected - */ + #[DataProvider('getFolderByDisplayNameProvider')] public function testGetFolderByDisplayName($input, $expected) { $client = $this->getClient(); @@ -291,12 +285,7 @@ public function testGetFolderByDisplayNameFail() $this->assertFalse($folder); } - /** - * Test that the syncFolderItems() function passes the correct arguments to it's client. - * - * @dataProvider listChangesProvider - * @param $folderInput - */ + #[DataProvider('listChangesProvider')] public function testListItemChanges($folderInput) { diff --git a/tests/src/CasterTest.php b/tests/src/CasterTest.php index c563c581..fdcffc94 100644 --- a/tests/src/CasterTest.php +++ b/tests/src/CasterTest.php @@ -10,28 +10,17 @@ use garethp\ews\Caster; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class CasterTest extends TestCase { - /** - * @param $input - * @param $type - * @param $expected - * - * @dataProvider castProvider - */ + #[DataProvider('castProvider')] public function testCast($input, $type, $expected) { $this->assertEquals($expected, Caster::cast($input, $type)); } - /** - * @param $from - * @param $to - * @param $expected - * - * @dataProvider castExistsProvider - */ + #[DataProvider('castExistsProvider')] public function testCastExists($from, $to, $expected) { $this->assertEquals($expected, Caster::castExists($from, $to));