Skip to content

Commit

Permalink
Message: Remove deprecated getter methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pprkut committed Dec 6, 2024
1 parent eba25b3 commit b0d307d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 137 deletions.
50 changes: 0 additions & 50 deletions ApnsPHP/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,6 @@ public function selfForRecipient(int $recipient = 0)
return $copy;
}

/**
* Get the number of recipients.
*
* @deprecated Use getRecipientsCount() instead.
*
* @return int Recipient's number.
*/
public function getRecipientsNumber(): int
{
return $this->getRecipientsCount();
}

/**
* Get the number of recipients.
*
Expand Down Expand Up @@ -419,44 +407,6 @@ public function setCustomProperty(string $name, $value): void
$this->customProperties[$name] = $value;
}

/**
* Get the first custom property name.
*
* @deprecated Use getCustomPropertyNames() instead.
*
* @return string The first custom property name.
*/
public function getCustomPropertyName(): string
{
if (empty($this->customProperties)) {
throw new Exception(
"No custom property exists!"
);
}

$keys = array_keys($this->customProperties);
return $keys[0];
}

/**
* Get the first custom property value.
*
* @deprecated Use getCustomProperty() instead.
*
* @return mixed The first custom property value.
*/
public function getCustomPropertyValue()
{
if (empty($this->customProperties)) {
throw new Exception(
"No custom property exists!"
);
}

$aKeys = array_keys($this->customProperties);
return $this->customProperties[$aKeys[0]];
}

/**
* Get all custom properties names.
*
Expand Down
2 changes: 1 addition & 1 deletion ApnsPHP/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ protected function getJsonWebToken(): string
public function add(Message $message): void
{
$messagePayload = $message->getPayload();
$recipients = $message->getRecipientsNumber();
$recipients = $message->getRecipientsCount();

$messageQueueLen = count($this->messageQueue);
for ($i = 0; $i < $recipients; $i++) {
Expand Down
83 changes: 0 additions & 83 deletions ApnsPHP/Tests/MessageGetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,70 +229,6 @@ public function testGetCustomIdentifier(): void
$this->assertSame('3491ac4b-0681-4c92-8308-d8d8441f4e64', $value);
}

/**
* Test that getCustomPropertyName() gets the first property name.
*
* @covers \ApnsPHP\Message::getCustomPropertyName
*/
public function testGetCustomPropertyNameReturnsFirstPropertyName(): void
{
$properties = [
'my-title' => 'My Title',
'my-message' => 'My Message',
];

$this->set_reflection_property_value('customProperties', $properties);

$value = $this->class->getCustomPropertyName();

$this->assertSame('my-title', $value);
}

/**
* Test that getCustomPropertyName() throws an exception if no custom property is set.
*
* @covers \ApnsPHP\Message::getCustomPropertyName
*/
public function testGetCustomPropertyNameThrowsExceptionWhenNoneSet(): void
{
$this->expectException('ApnsPHP\Message\Exception');
$this->expectExceptionMessage('No custom property exists!');

$this->class->getCustomPropertyName();
}

/**
* Test that getCustomPropertyValue() gets the first property value.
*
* @covers \ApnsPHP\Message::getCustomPropertyValue
*/
public function testGetCustomPropertyValueReturnsFirstPropertyValue(): void
{
$properties = [
'my-title' => 'My Title',
'my-message' => 'My Message',
];

$this->set_reflection_property_value('customProperties', $properties);

$value = $this->class->getCustomPropertyValue();

$this->assertSame('My Title', $value);
}

/**
* Test that getCustomPropertyValue() throws an exception if no custom property is set.
*
* @covers \ApnsPHP\Message::getCustomPropertyValue
*/
public function testGetCustomPropertyValueThrowsExceptionWhenNoneSet(): void
{
$this->expectException('ApnsPHP\Message\Exception');
$this->expectExceptionMessage('No custom property exists!');

$this->class->getCustomPropertyValue();
}

/**
* Test that getCustomPropertyValue() successfully returns an existing property.
*
Expand Down Expand Up @@ -363,25 +299,6 @@ public function testGetCustomPropertyNamesWithoutPropertiesSet(): void
$this->assertArrayEmpty($value);
}

/**
* Test that getRecipientsNumber() returns the count of set device tokens.
*
* @covers \ApnsPHP\Message::getRecipientsNumber
*/
public function testGetRecipientsNumber(): void
{
$tokens = [
'1e82db91c7ceddd72bf33d74ae052ac9c84a065b35148ac401388843106a7485L',
'1e82db91c7ceddd72bf33d74ae052ac9c84a065b35148ac401388843106a7485B'
];

$this->set_reflection_property_value('deviceTokens', $tokens);

$value = $this->class->getRecipientsNumber();

$this->assertSame(2, $value);
}

/**
* Test that getRecipientsCount() returns the count of set device tokens.
*
Expand Down
6 changes: 3 additions & 3 deletions ApnsPHP/Tests/PushAddTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testAddOneMessage(): void
->will($this->returnValue('payload'));

$this->message->expects($this->once())
->method('getRecipientsNumber')
->method('getRecipientsCount')
->will($this->returnValue(1));

$this->message->expects($this->once())
Expand Down Expand Up @@ -63,7 +63,7 @@ public function testAddMultipleMessages(): void
->will($this->returnValue('payload'));

$this->message->expects($this->once())
->method('getRecipientsNumber')
->method('getRecipientsCount')
->will($this->returnValue(4));

$this->message->expects($this->exactly(4))
Expand All @@ -90,7 +90,7 @@ public function testAddDoesNothing(): void
->will($this->returnValue('payload'));

$this->message->expects($this->once())
->method('getRecipientsNumber')
->method('getRecipientsCount')
->will($this->returnValue(0));

$this->class->add($this->message);
Expand Down

0 comments on commit b0d307d

Please sign in to comment.