Skip to content

Commit

Permalink
chore: update PHPUnit to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed Nov 8, 2024
1 parent 411c308 commit dfdf9dd
Show file tree
Hide file tree
Showing 27 changed files with 180 additions and 236 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/php-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
extensions: uopz
tools: phpunit:9.5.x

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
Expand All @@ -45,7 +44,7 @@ jobs:
chmod 000 server_certificates_bundle_unreadable.pem
- name: Run PHPUnit
run: phpunit -c phpunit.xml
run: ./vendor/bin/phpunit -c phpunit.xml

sample_push:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @covers \ApnsPHP\Message\CustomMessage
*/
class CustomMessageGetPayloadDictionaryTest extends CustomMessageTest
class CustomMessageGetPayloadDictionaryTest extends CustomMessageTestBase
{
/**
* Test that getPayloadDictionary returns complete payload with body if locKey isn't set
Expand Down Expand Up @@ -60,7 +60,7 @@ public function testGetPayloadDictionaryReturnsCompletePayloadWithoutLocKey(): v
'name' => 'value'
];

$result = $this->get_accessible_reflection_method('getPayloadDictionary')->invoke($this->class);
$result = $this->get_reflection_method('getPayloadDictionary')->invoke($this->class);

$this->assertEquals($payload, $result);
}
Expand Down Expand Up @@ -109,7 +109,7 @@ public function testGetPayloadDictionaryReturnsCompletePayloadWithoutBody(): voi
'name' => 'value'
];

$result = $this->get_accessible_reflection_method('getPayloadDictionary')->invoke($this->class);
$result = $this->get_reflection_method('getPayloadDictionary')->invoke($this->class);

$this->assertEquals($payload, $result);
}
Expand All @@ -123,7 +123,7 @@ public function testGetPayloadDictionaryReturnsEmptyPayload(): void
{
$payload = [ 'aps' => [ 'alert' => [] ] ];

$result = $this->get_accessible_reflection_method('getPayloadDictionary')->invoke($this->class);
$result = $this->get_reflection_method('getPayloadDictionary')->invoke($this->class);

$this->assertEquals($payload, $result);
}
Expand Down
2 changes: 1 addition & 1 deletion ApnsPHP/Message/Tests/CustomMessageGetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @covers \ApnsPHP\Message\CustomMessage
*/
class CustomMessageGetTest extends CustomMessageTest
class CustomMessageGetTest extends CustomMessageTestBase
{
/**
* Test that getActionLocKey() gets the view button title.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,30 @@
*
* @covers \ApnsPHP\Message\CustomMessage
*/
abstract class CustomMessageTest extends LunrBaseTest
abstract class CustomMessageTestBase extends LunrBaseTest
{

Check failure on line 24 in ApnsPHP/Message/Tests/CustomMessageTestBase.php

View workflow job for this annotation

GitHub Actions / PHPCS

Opening brace must not be followed by a blank line

/**
* Class to test
* @var CustomMessage
*/
protected CustomMessage $class;

/**
* TestCase constructor
*/
public function setUp(): void
{
$this->reflection = new ReflectionClass('ApnsPHP\Message\CustomMessage');
$this->class = new CustomMessage();
$this->class = new CustomMessage();
$this->baseSetUp($this->class);
}

/**
* TestCase destructor
*/
public function tearDown(): void
{
parent::tearDown();
unset($this->class);
unset($this->reflection);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @covers \ApnsPHP\Message\SafariMessage
*/
class SafariMessageGetPayloadDictionaryTest extends SafariMessageTest
class SafariMessageGetPayloadDictionaryTest extends SafariMessageTestBase
{
/**
* Test that getPayloadDictionary returns complete payload
Expand All @@ -40,7 +40,7 @@ public function testGetPayloadDictionaryReturnsCompletePayload(): void
]
];

$result = $this->get_accessible_reflection_method('getPayloadDictionary')->invoke($this->class);
$result = $this->get_reflection_method('getPayloadDictionary')->invoke($this->class);

$this->assertEquals($payload, $result);
}
Expand All @@ -54,7 +54,7 @@ public function testGetPayloadDictionaryReturnsEmptyPayload(): void
{
$payload = [ 'aps' => [ 'alert' => [] ] ];

$result = $this->get_accessible_reflection_method('getPayloadDictionary')->invoke($this->class);
$result = $this->get_reflection_method('getPayloadDictionary')->invoke($this->class);

$this->assertEquals($payload, $result);
}
Expand Down
2 changes: 1 addition & 1 deletion ApnsPHP/Message/Tests/SafariMessageGetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @covers \ApnsPHP\Message\SafariMessage
*/
class SafariMessageGetTest extends SafariMessageTest
class SafariMessageGetTest extends SafariMessageTestBase
{
/**
* Test that getAction() gets the label of the action button.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,30 @@
*
* @covers \ApnsPHP\Message\SafariMessage
*/
abstract class SafariMessageTest extends LunrBaseTest
abstract class SafariMessageTestBase extends LunrBaseTest
{

Check failure on line 24 in ApnsPHP/Message/Tests/SafariMessageTestBase.php

View workflow job for this annotation

GitHub Actions / PHPCS

Opening brace must not be followed by a blank line

/**
* Class to test
* @var SafariMessage
*/
protected SafariMessage $class;

/**
* TestCase constructor
*/
public function setUp(): void
{
$this->reflection = new ReflectionClass('ApnsPHP\Message\SafariMessage');
$this->class = new SafariMessage();
$this->baseSetUp($this->class);
}

/**
* TestCase destructor
*/
public function tearDown(): void
{
parent::tearDown();
unset($this->class);
unset($this->reflection);
}
}
2 changes: 1 addition & 1 deletion ApnsPHP/Tests/MessageAddRecipientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @covers \ApnsPHP\Message
*/
class MessageAddRecipientTest extends MessageTest
class MessageAddRecipientTest extends MessageTestBase
{
/**
* Test that addRecipient throws exception on invalid token
Expand Down
8 changes: 4 additions & 4 deletions ApnsPHP/Tests/MessageGetPayloadDictionaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @covers \ApnsPHP\Message
*/
class MessageGetPayloadDictionaryTest extends MessageTest
class MessageGetPayloadDictionaryTest extends MessageTestBase
{
/**
* Test that getPayloadDictionary returns complete payload
Expand Down Expand Up @@ -52,7 +52,7 @@ public function testGetPayloadDictionaryReturnsCompletePayload(): void
'name' => 'value'
];

$result = $this->get_accessible_reflection_method('getPayloadDictionary')->invoke($this->class);
$result = $this->get_reflection_method('getPayloadDictionary')->invoke($this->class);

$this->assertEquals($payload, $result);
}
Expand Down Expand Up @@ -88,7 +88,7 @@ public function testGetPayloadDictionaryWithoutTitle(): void
'name' => 'value'
];

$result = $this->get_accessible_reflection_method('getPayloadDictionary')->invoke($this->class);
$result = $this->get_reflection_method('getPayloadDictionary')->invoke($this->class);

$this->assertEquals($payload, $result);
}
Expand All @@ -102,7 +102,7 @@ public function testGetPayloadDictionaryReturnsEmptyPayload(): void
{
$payload = [ 'aps' => [] ];

$result = $this->get_accessible_reflection_method('getPayloadDictionary')->invoke($this->class);
$result = $this->get_reflection_method('getPayloadDictionary')->invoke($this->class);

$this->assertEquals($payload, $result);
}
Expand Down
4 changes: 2 additions & 2 deletions ApnsPHP/Tests/MessageGetPayloadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @covers \ApnsPHP\Message
*/
class MessageGetPayloadTest extends MessageTest
class MessageGetPayloadTest extends MessageTestBase
{
/**
* Test that getPayload() returns complete JSON encoded payload
Expand Down Expand Up @@ -161,7 +161,7 @@ public function testCastToStringReturnsEmptyStringOnTooLongPayloadWithoutAutoAdj
*
* @return string String of certain size in bytes
*/
private function getLargeString($size): string
private function getLargeString(int $size): string
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$length = strlen($characters);
Expand Down
2 changes: 1 addition & 1 deletion ApnsPHP/Tests/MessageGetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* @covers \ApnsPHP\Message
*/
class MessageGetTest extends MessageTest
class MessageGetTest extends MessageTestBase
{
/**
* Test that getText() gets the message text.
Expand Down
6 changes: 3 additions & 3 deletions ApnsPHP/Tests/MessageSelfForRecipientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
*
* @covers \ApnsPHP\Message
*/
class MessageSelfForRecipientTest extends MessageTest
class MessageSelfForRecipientTest extends MessageTestBase
{
/**
* Test that selfForRecipient throws exception on invalid index
*
* @covers \ApnsPHP\Message::selfForRecipient
*/
public function testselfForRecipientThrowsExceptionOnInvalidIndex(): void
public function testSelfForRecipientThrowsExceptionOnInvalidIndex(): void
{
$this->expectException('ApnsPHP\Exception');
$this->expectExceptionMessage('No recipient at index \'1\'');
Expand All @@ -37,7 +37,7 @@ public function testselfForRecipientThrowsExceptionOnInvalidIndex(): void
*
* @covers \ApnsPHP\Message::selfForRecipient
*/
public function testselfForRecipientGetsMessage(): void
public function testSelfForRecipientGetsMessage(): void
{
$token = '1e82db91c7ceddd72bf33d74ae052ac9c84a065b35148ac401388843106a7485';
$message = new Message($token);
Expand Down
10 changes: 5 additions & 5 deletions ApnsPHP/Tests/MessageSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
*
* @covers \ApnsPHP\Message
*/
class MessageSetTest extends MessageTest
class MessageSetTest extends MessageTestBase
{
/**
* Unit test data provider for reserved apple namespace keys.
*
* @return array Variations of the reserved apple namespace key
*/
public function reservedAppleNamespaceKeyProvider(): array
public static function reservedAppleNamespaceKeyProvider(): array
{
$data = [];
$data[] = [ 'aps' ];
Expand All @@ -40,7 +40,7 @@ public function reservedAppleNamespaceKeyProvider(): array
*
* @return array Variations of valid custom identifiers
*/
public function validCustomIdentifierProvider(): array
public static function validCustomIdentifierProvider(): array
{
$data = [];
$data[] = [ '3491ac4b-0681-4c92-8308-d8d8441f4e64' ];
Expand All @@ -54,7 +54,7 @@ public function validCustomIdentifierProvider(): array
*
* @return array Variations of a valid message priority
*/
public function validPriorityProvider(): array
public static function validPriorityProvider(): array
{
$data = [];
$data[] = [ Priority::PrioritizePowerUsage ];
Expand All @@ -69,7 +69,7 @@ public function validPriorityProvider(): array
*
* @return array Variations of a valid push type
*/
public function validPushTypeProvider(): array
public static function validPushTypeProvider(): array
{
$data = [];
$data[] = [ PushType::Alert ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,30 @@
*
* @covers \ApnsPHP\Message
*/
abstract class MessageTest extends LunrBaseTest
abstract class MessageTestBase extends LunrBaseTest
{

Check failure on line 25 in ApnsPHP/Tests/MessageTestBase.php

View workflow job for this annotation

GitHub Actions / PHPCS

Opening brace must not be followed by a blank line

/**
* Class to test
* @var Message
*/
protected Message $class;

/**
* TestCase constructor
*/
public function setUp(): void
{
$this->reflection = new ReflectionClass('ApnsPHP\Message');
$this->class = new Message();
$this->class = new Message();
$this->baseSetUp($this->class);
}

/**
* TestCase destructor
*/
public function tearDown(): void
{
parent::tearDown();
unset($this->class);
unset($this->reflection);
}
}
Loading

0 comments on commit dfdf9dd

Please sign in to comment.