diff --git a/.travis.yml b/.travis.yml
index 1806edf..7f38c26 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,18 +1,22 @@
+sudo: false
+
language: php
-php:
- - 5.3
- - 5.4
- - 5.5
- - 5.6
- - hhvm
+matrix:
+ include:
+ - php: 5.6
+ - php: 7.0
+ - php: 7.1
+ env:
+ - CS_CHECK=true
+ - php: 7.2
before_install:
- - cp tests/TestConfiguration.php.travis tests/TestConfiguration.php
- - composer install --dev
+ - composer install --no-interaction
script:
- - phpunit -c tests/phpunit.xml.dist
+ - ./vendor/bin/phpunit
+ - if [[ $CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs ; fi
notifications:
- #irc: "irc.freenode.org#zftalk.2"
\ No newline at end of file
+ email: false
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 66901f0..840aa38 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,10 +2,12 @@
All notable changes to this project will be documented in this file, in reverse chronological order by release.
-## 1.3.0 - TBD
+## 1.3.0 - 2018-05-08
### Added
+- [#63](https://github.com/zendframework/ZendService_Apple_Apns/pull/63) adds support for PHP 7.1 and 7.2.
+
- [#53](https://github.com/zendframework/ZendService_Apple_Apns/pull/53) adds support for the mutable-content Notification field within the `Message` implementation.
- [#48](https://github.com/zendframework/ZendService_Apple_Apns/pull/48) adds two new methods to `ZendService\Apple\Apns\Message\Alert`: `setAction($key)` and `getAction()`.
@@ -21,7 +23,9 @@ All notable changes to this project will be documented in this file, in reverse
### Removed
-- Nothing.
+- [#63](https://github.com/zendframework/ZendService_Apple_Apns/pull/63) removes support for PHP 5.3, 5.4, and 5.5.
+
+- [#63](https://github.com/zendframework/ZendService_Apple_Apns/pull/63) removes support for HHVM.
### Fixed
diff --git a/LICENSE.txt b/LICENSE.md
similarity index 59%
rename from LICENSE.txt
rename to LICENSE.md
index 5ad81e9..d44ab5d 100755
--- a/LICENSE.txt
+++ b/LICENSE.md
@@ -1,19 +1,19 @@
-Copyright (c) 2005-2014, Zend Technologies USA, Inc.
+Copyright (c) 2005-2018, Zend Technologies USA, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+- Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
+- Redistributions in binary form must reproduce the above copyright notice, this
+ list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
- * Neither the name of Zend Technologies USA, Inc. nor the names of its
- contributors may be used to endorse or promote products derived from this
- software without specific prior written permission.
+- Neither the name of Zend Technologies USA, Inc. nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
diff --git a/README.md b/README.md
index 23d927d..184ac6a 100755
--- a/README.md
+++ b/README.md
@@ -4,11 +4,11 @@ ZendService\Apple\Apns [![Build Status](https://travis-ci.org/zendframework/Zend
Provides support for Apple push notifications.
-## Requirements ##
+## Requirements
-* PHP >= 5.3.3
+* PHP >= 5.6
-## Getting Started ##
+## Getting Started
Install this library using [Composer](http://getcomposer.org/):
@@ -16,7 +16,7 @@ Install this library using [Composer](http://getcomposer.org/):
$ composer require zendframework/zendservice-apple-apns
```
-## Documentation ##
+## Documentation
The documentation can be found at: http://framework.zend.com/manual/current/en/modules/zendservice.apple.apns.html
diff --git a/composer.json b/composer.json
index 9347c96..cd3240d 100755
--- a/composer.json
+++ b/composer.json
@@ -1,33 +1,47 @@
{
"name": "zendframework/zendservice-apple-apns",
- "description": "OOP Zend Framework 2 wrapper for Apple Push Notification Service",
- "type": "library",
+ "description": "OOP Zend Framework wrapper for Apple Push Notification Service",
+ "license": "BSD-3-Clause",
"keywords": [
- "zf2",
+ "zf",
+ "zendframework",
"apns",
"push",
"notification",
"apple"
],
- "homepage": "https://packages.zendframework.com/",
- "license": "BSD-3-Clause",
+ "support": {
+ "issues": "https://github.com/zendframework/ZendService_Apple_Apns/issues",
+ "source": "https://github.com/zendframework/ZendService_Apple_Apns",
+ "rss": "https://github.com/zendframework/ZendService_Apple_Apns/releases.atom",
+ "chat": "https://zendframework-slack.herokuapp.com",
+ "forum": "https://discourse.zendframework.com/c/questions/components"
+ },
+ "require": {
+ "php": "^5.6 || ^7.0",
+ "zendframework/zend-json": "^2.0 || ^3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.5",
+ "zendframework/zend-coding-standard": "~1.0.0"
+ },
"autoload": {
- "psr-0": {
- "ZendService\\Apple\\Apns\\": "library/",
- "ZendService\\Apple\\Exception\\": "library/"
+ "psr-4": {
+ "ZendService\\Apple\\": "src/"
}
},
- "repositories": [
- {
- "type": "composer",
- "url": "https://packages.zendframework.com/"
+ "autoload-dev": {
+ "psr-4": {
+ "ZendServiceTest\\Apple\\": "test/"
}
- ],
- "require": {
- "php": ">=5.3.3",
- "zendframework/zend-json": "^2.0|^3.0"
},
- "require-dev": {
- "phpunit/phpunit": "3.7.*"
+ "config": {
+ "sort-packages": true
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.3.x-dev",
+ "dev-develop": "1.4.x-dev"
+ }
}
}
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..4bfc5d0
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+ src
+ test
+
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100755
index 0000000..36b2d67
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,17 @@
+
+
+
+
+ ./test
+
+
+
+
+
+ ./src
+
+
+
diff --git a/library/ZendService/Apple/Apns/Client/AbstractClient.php b/src/Apns/Client/AbstractClient.php
similarity index 91%
rename from library/ZendService/Apple/Apns/Client/AbstractClient.php
rename to src/Apns/Client/AbstractClient.php
index b50228e..c6fa72e 100644
--- a/library/ZendService/Apple/Apns/Client/AbstractClient.php
+++ b/src/Apns/Client/AbstractClient.php
@@ -29,7 +29,7 @@ abstract class AbstractClient
* APNS URIs
* @var array
*/
- protected $uris = array();
+ protected $uris = [];
/**
* Is Connected
@@ -59,19 +59,19 @@ public function open($environment, $certificate, $passPhrase = null)
throw new Exception\RuntimeException('Connection has already been opened and must be closed');
}
- if (!array_key_exists($environment, $this->uris)) {
+ if (! array_key_exists($environment, $this->uris)) {
throw new Exception\InvalidArgumentException('Environment must be one of PRODUCTION_URI or SANDBOX_URI');
}
- if (!is_string($certificate) || !file_exists($certificate)) {
+ if (! is_string($certificate) || ! file_exists($certificate)) {
throw new Exception\InvalidArgumentException('Certificate must be a valid path to a APNS certificate');
}
- $sslOptions = array(
+ $sslOptions = [
'local_cert' => $certificate,
- );
+ ];
if ($passPhrase !== null) {
- if (!is_scalar($passPhrase)) {
+ if (! is_scalar($passPhrase)) {
throw new Exception\InvalidArgumentException('SSL passphrase must be a scalar');
}
$sslOptions['passphrase'] = $passPhrase;
@@ -103,9 +103,9 @@ protected function connect($host, array $ssl)
ini_get('default_socket_timeout'),
STREAM_CLIENT_CONNECT,
stream_context_create(
- array(
+ [
'ssl' => $ssl,
- )
+ ]
)
);
} catch (StreamSocketClientException $e) {
@@ -120,7 +120,7 @@ protected function connect($host, array $ssl)
restore_error_handler();
- if (!$this->socket) {
+ if (! $this->socket) {
throw new Exception\RuntimeException(sprintf(
'Unable to connect: %s: %d (%s)',
$host,
@@ -167,11 +167,11 @@ public function isConnected()
*/
protected function read($length = 6)
{
- if (!$this->isConnected()) {
+ if (! $this->isConnected()) {
throw new Exception\RuntimeException('You must open the connection prior to reading data');
}
$data = false;
- $read = array($this->socket);
+ $read = [$this->socket];
$null = null;
if (0 < @stream_select($read, $null, $null, 1, 0)) {
@@ -189,7 +189,7 @@ protected function read($length = 6)
*/
protected function write($payload)
{
- if (!$this->isConnected()) {
+ if (! $this->isConnected()) {
throw new Exception\RuntimeException('You must open the connection prior to writing data');
}
diff --git a/library/ZendService/Apple/Apns/Client/Feedback.php b/src/Apns/Client/Feedback.php
similarity index 91%
rename from library/ZendService/Apple/Apns/Client/Feedback.php
rename to src/Apns/Client/Feedback.php
index 3261415..209c53c 100644
--- a/library/ZendService/Apple/Apns/Client/Feedback.php
+++ b/src/Apns/Client/Feedback.php
@@ -22,10 +22,10 @@ class Feedback extends AbstractClient
* APNS URIs
* @var array
*/
- protected $uris = array(
+ protected $uris = [
'tls://feedback.sandbox.push.apple.com:2196',
'tls://feedback.push.apple.com:2196'
- );
+ ];
/**
* Get Feedback
@@ -34,11 +34,11 @@ class Feedback extends AbstractClient
*/
public function feedback()
{
- if (!$this->isConnected()) {
+ if (! $this->isConnected()) {
throw new Exception\RuntimeException('You must first open the connection by calling open()');
}
- $tokens = array();
+ $tokens = [];
while ($token = $this->read(38)) {
$tokens[] = new FeedbackResponse($token);
}
diff --git a/library/ZendService/Apple/Apns/Client/Message.php b/src/Apns/Client/Message.php
similarity index 95%
rename from library/ZendService/Apple/Apns/Client/Message.php
rename to src/Apns/Client/Message.php
index a18077b..3fdd59c 100644
--- a/library/ZendService/Apple/Apns/Client/Message.php
+++ b/src/Apns/Client/Message.php
@@ -29,10 +29,10 @@ class Message extends AbstractClient
* APNS URIs
* @var array
*/
- protected $uris = array(
+ protected $uris = [
'tls://gateway.sandbox.push.apple.com:2195',
'tls://gateway.push.apple.com:2195',
- );
+ ];
/**
* Send Message
@@ -42,7 +42,7 @@ class Message extends AbstractClient
*/
public function send(ApnsMessage $message)
{
- if (!$this->isConnected()) {
+ if (! $this->isConnected()) {
throw new Exception\RuntimeException('You must first open the connection by calling open()');
}
diff --git a/library/ZendService/Apple/Apns/Message.php b/src/Apns/Message.php
similarity index 86%
rename from library/ZendService/Apple/Apns/Message.php
rename to src/Apns/Message.php
index e5fe0d4..bb1a546 100644
--- a/library/ZendService/Apple/Apns/Message.php
+++ b/src/Apns/Message.php
@@ -102,7 +102,7 @@ public function getId()
*/
public function setId($id)
{
- if (!is_scalar($id)) {
+ if (! is_scalar($id)) {
throw new Exception\InvalidArgumentException('Identifier must be a scalar value');
}
$this->id = $id;
@@ -128,25 +128,25 @@ public function getToken()
*/
public function setToken($token)
{
- if (!is_string($token)) {
+ if (! is_string($token)) {
throw new Exception\InvalidArgumentException(sprintf(
- 'Device token must be a string, "%s" given.',
- gettype($token)
+ 'Device token must be a string, "%s" given.',
+ gettype($token)
));
}
if (preg_match('/[^0-9a-f]/i', $token)) {
throw new Exception\InvalidArgumentException(sprintf(
- 'Device token must be mask "%s". Token given: "%s"',
- '/[^0-9a-f]/',
- $token
+ 'Device token must be mask "%s". Token given: "%s"',
+ '/[^0-9a-f]/',
+ $token
));
}
if (strlen($token) != 64) {
throw new Exception\InvalidArgumentException(sprintf(
- 'Device token must be a 64 charsets, Token length given: %d.',
- mb_strlen($token)
+ 'Device token must be a 64 charsets, Token length given: %d.',
+ mb_strlen($token)
));
}
@@ -175,7 +175,7 @@ public function setExpire($expire)
{
if ($expire instanceof \DateTime) {
$expire = $expire->getTimestamp();
- } elseif (!is_numeric($expire) || $expire != (int) $expire) {
+ } elseif (! is_numeric($expire) || $expire != (int) $expire) {
throw new Exception\InvalidArgumentException('Expiration must be a DateTime object or a unix timestamp');
}
$this->expire = $expire;
@@ -201,7 +201,7 @@ public function getAlert()
*/
public function setAlert($alert)
{
- if (!$alert instanceof Message\Alert && !is_null($alert)) {
+ if (! $alert instanceof Message\Alert && ! is_null($alert)) {
$alert = new Message\Alert($alert);
}
$this->alert = $alert;
@@ -227,7 +227,7 @@ public function getBadge()
*/
public function setBadge($badge)
{
- if ($badge !== null && !$badge == (int) $badge) {
+ if ($badge !== null && ! $badge == (int) $badge) {
throw new Exception\InvalidArgumentException('Badge must be null or an integer');
}
$this->badge = $badge;
@@ -253,7 +253,7 @@ public function getSound()
*/
public function setSound($sound)
{
- if ($sound !== null && !is_string($sound)) {
+ if ($sound !== null && ! is_string($sound)) {
throw new Exception\InvalidArgumentException('Sound must be null or a string');
}
$this->sound = $sound;
@@ -269,7 +269,7 @@ public function setSound($sound)
*/
public function setMutableContent($value)
{
- if ($value !== null && !is_int($value)) {
+ if ($value !== null && ! is_int($value)) {
throw new Exception\InvalidArgumentException(
'Mutable Content must be null or an integer, received: ' . gettype($value)
);
@@ -302,7 +302,7 @@ public function getContentAvailable()
*/
public function setContentAvailable($value)
{
- if ($value !== null && !is_int($value)) {
+ if ($value !== null && ! is_int($value)) {
throw new Exception\InvalidArgumentException('Content Available must be null or an integer');
}
$this->contentAvailable = $value;
@@ -328,7 +328,7 @@ public function getCategory()
*/
public function setCategory($category)
{
- if ($category !== null && !is_string($category)) {
+ if ($category !== null && ! is_string($category)) {
throw new Exception\InvalidArgumentException('Category must be null or a string');
}
$this->category = $category;
@@ -395,34 +395,34 @@ public function setCustom(array $custom)
*/
public function getPayload()
{
- $message = array();
- $aps = array();
+ $message = [];
+ $aps = [];
if ($this->alert && ($alert = $this->alert->getPayload())) {
$aps['alert'] = $alert;
}
- if (!is_null($this->badge)) {
+ if (! is_null($this->badge)) {
$aps['badge'] = $this->badge;
}
- if (!is_null($this->sound)) {
+ if (! is_null($this->sound)) {
$aps['sound'] = $this->sound;
}
- if (!is_null($this->mutableContent)) {
+ if (! is_null($this->mutableContent)) {
$aps['mutable-content'] = $this->mutableContent;
}
- if (!is_null($this->contentAvailable)) {
+ if (! is_null($this->contentAvailable)) {
$aps['content-available'] = $this->contentAvailable;
}
- if (!is_null($this->category)) {
+ if (! is_null($this->category)) {
$aps['category'] = $this->category;
}
- if (!is_null($this->urlArgs)) {
+ if (! is_null($this->urlArgs)) {
$aps['url-args'] = $this->urlArgs;
}
- if (!empty($this->custom)) {
+ if (! empty($this->custom)) {
$message = array_merge($this->custom, $message);
}
- $message['aps'] = empty($aps) ? (object) array() : $aps;
+ $message['aps'] = empty($aps) ? (object) [] : $aps;
return $message;
}
diff --git a/library/ZendService/Apple/Apns/Message/Alert.php b/src/Apns/Message/Alert.php
similarity index 89%
rename from library/ZendService/Apple/Apns/Message/Alert.php
rename to src/Apns/Message/Alert.php
index a34634f..cc85345 100644
--- a/library/ZendService/Apple/Apns/Message/Alert.php
+++ b/src/Apns/Message/Alert.php
@@ -22,7 +22,7 @@ class Alert
* @var string|null
*/
protected $body;
-
+
/**
* Action
* @var string|null
@@ -52,19 +52,19 @@ class Alert
* @var string|null
*/
protected $launchImage;
-
+
/**
* Message Title
* @var string|null
*/
protected $title;
-
+
/**
* Title Locale Key
* @var string|null
*/
protected $titleLocKey;
-
+
/**
* Title Locale Arguments
* @var array|null
@@ -81,8 +81,16 @@ class Alert
* @param string $launchImage
* @return Alert
*/
- public function __construct($body = null, $actionLocKey = null, $locKey = null, $locArgs = null, $launchImage = null, $title = null, $titleLocKey = null, $titleLocArgs = null)
- {
+ public function __construct(
+ $body = null,
+ $actionLocKey = null,
+ $locKey = null,
+ $locArgs = null,
+ $launchImage = null,
+ $title = null,
+ $titleLocKey = null,
+ $titleLocArgs = null
+ ) {
if ($body !== null) {
$this->setBody($body);
}
@@ -127,14 +135,14 @@ public function getBody()
*/
public function setBody($body)
{
- if (!is_null($body) && !is_scalar($body)) {
+ if (! is_null($body) && ! is_scalar($body)) {
throw new Exception\InvalidArgumentException('Body must be null OR a scalar value');
}
$this->body = $body;
return $this;
}
-
+
/**
* Get Action
*
@@ -153,14 +161,14 @@ public function getAction()
*/
public function setAction($key)
{
- if (!is_null($key) && !is_scalar($key)) {
+ if (! is_null($key) && ! is_scalar($key)) {
throw new Exception\InvalidArgumentException('Action must be null OR a scalar value');
}
$this->action = $key;
return $this;
}
-
+
/**
* Get Action Locale Key
*
@@ -179,7 +187,7 @@ public function getActionLocKey()
*/
public function setActionLocKey($key)
{
- if (!is_null($key) && !is_scalar($key)) {
+ if (! is_null($key) && ! is_scalar($key)) {
throw new Exception\InvalidArgumentException('ActionLocKey must be null OR a scalar value');
}
$this->actionLocKey = $key;
@@ -205,7 +213,7 @@ public function getLocKey()
*/
public function setLocKey($key)
{
- if (!is_null($key) && !is_scalar($key)) {
+ if (! is_null($key) && ! is_scalar($key)) {
throw new Exception\InvalidArgumentException('LocKey must be null OR a scalar value');
}
$this->locKey = $key;
@@ -232,7 +240,7 @@ public function getLocArgs()
public function setLocArgs(array $args)
{
foreach ($args as $a) {
- if (!is_scalar($a)) {
+ if (! is_scalar($a)) {
throw new Exception\InvalidArgumentException('Arguments must only contain scalar values');
}
}
@@ -259,10 +267,10 @@ public function getLaunchImage()
*/
public function setLaunchImage($image)
{
- if (!is_null($image) && !is_scalar($image)) {
+ if (! is_null($image) && ! is_scalar($image)) {
throw new Exception\InvalidArgumentException('Launch image must be null OR a scalar value');
}
- $this->launchImage = $image;
+ $this->launchImage = $image;
return $this;
}
@@ -285,14 +293,14 @@ public function getTitle()
*/
public function setTitle($title)
{
- if (!is_null($title) && !is_scalar($title)) {
+ if (! is_null($title) && ! is_scalar($title)) {
throw new Exception\InvalidArgumentException('Title must be null OR a scalar value');
}
$this->title = $title;
return $this;
}
-
+
/**
* Get Title Locale Key
*
@@ -311,14 +319,14 @@ public function getTitleLocKey()
*/
public function setTitleLocKey($key)
{
- if (!is_null($key) && !is_scalar($key)) {
+ if (! is_null($key) && ! is_scalar($key)) {
throw new Exception\InvalidArgumentException('TitleLocKey must be null OR a scalar value');
}
$this->titleLocKey = $key;
return $this;
}
-
+
/**
* Get Title Locale Arguments
*
@@ -338,7 +346,7 @@ public function getTitleLocArgs()
public function setTitleLocArgs(array $args)
{
foreach ($args as $a) {
- if (!is_scalar($a)) {
+ if (! is_scalar($a)) {
throw new Exception\InvalidArgumentException('Title Arguments must only contain scalar values');
}
}
@@ -360,9 +368,9 @@ public function getPayload()
return null;
}
- $alert = array();
+ $alert = [];
foreach ($vars as $key => $value) {
- if (!is_null($value)) {
+ if (! is_null($value)) {
$key = strtolower(preg_replace('/([a-z])([A-Z])/', '$1-$2', $key));
$alert[$key] = $value;
}
diff --git a/library/ZendService/Apple/Apns/Response/Feedback.php b/src/Apns/Response/Feedback.php
similarity index 98%
rename from library/ZendService/Apple/Apns/Response/Feedback.php
rename to src/Apns/Response/Feedback.php
index ce8d2a3..b94eeb3 100644
--- a/library/ZendService/Apple/Apns/Response/Feedback.php
+++ b/src/Apns/Response/Feedback.php
@@ -59,7 +59,7 @@ public function getToken()
*/
public function setToken($token)
{
- if (!is_scalar($token)) {
+ if (! is_scalar($token)) {
throw new Exception\InvalidArgumentException('Token must be a scalar value');
}
$this->token = $token;
diff --git a/library/ZendService/Apple/Apns/Response/Message.php b/src/Apns/Response/Message.php
similarity index 97%
rename from library/ZendService/Apple/Apns/Response/Message.php
rename to src/Apns/Response/Message.php
index 5e328bd..837ab69 100644
--- a/library/ZendService/Apple/Apns/Response/Message.php
+++ b/src/Apns/Response/Message.php
@@ -107,7 +107,7 @@ public function getId()
*/
public function setId($id)
{
- if (!is_scalar($id)) {
+ if (! is_scalar($id)) {
throw new Exception\InvalidArgumentException('Identifier must be a scalar value');
}
$this->id = $id;
@@ -123,7 +123,7 @@ public function setId($id)
*/
public function parseRawResponse($rawResponse)
{
- if (!is_scalar($rawResponse)) {
+ if (! is_scalar($rawResponse)) {
throw new Exception\InvalidArgumentException('Response must be a scalar value');
}
diff --git a/library/ZendService/Apple/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php
similarity index 100%
rename from library/ZendService/Apple/Exception/InvalidArgumentException.php
rename to src/Exception/InvalidArgumentException.php
diff --git a/library/ZendService/Apple/Exception/RuntimeException.php b/src/Exception/RuntimeException.php
similarity index 100%
rename from library/ZendService/Apple/Exception/RuntimeException.php
rename to src/Exception/RuntimeException.php
diff --git a/library/ZendService/Apple/Exception/StreamSocketClientException.php b/src/Exception/StreamSocketClientException.php
similarity index 100%
rename from library/ZendService/Apple/Exception/StreamSocketClientException.php
rename to src/Exception/StreamSocketClientException.php
diff --git a/tests/ZendService/Apple/Apns/FeedbackClientTest.php b/test/Apns/FeedbackClientTest.php
similarity index 94%
rename from tests/ZendService/Apple/Apns/FeedbackClientTest.php
rename to test/Apns/FeedbackClientTest.php
index 1435437..205fabd 100644
--- a/tests/ZendService/Apple/Apns/FeedbackClientTest.php
+++ b/test/Apns/FeedbackClientTest.php
@@ -10,6 +10,7 @@
namespace ZendServiceTest\Apple\Apns;
+use PHPUnit\Framework\TestCase;
use ZendServiceTest\Apple\Apns\TestAsset\FeedbackClient;
/**
@@ -20,7 +21,7 @@
* @group ZendService_Apple
* @group ZendService_Apple_Apns
*/
-class FeedbackClientTest extends \PHPUnit_Framework_TestCase
+class FeedbackClientTest extends TestCase
{
public function setUp()
{
diff --git a/tests/ZendService/Apple/Apns/MessageClientTest.php b/test/Apns/MessageClientTest.php
similarity index 92%
rename from tests/ZendService/Apple/Apns/MessageClientTest.php
rename to test/Apns/MessageClientTest.php
index dd6bf03..99f294a 100644
--- a/tests/ZendService/Apple/Apns/MessageClientTest.php
+++ b/test/Apns/MessageClientTest.php
@@ -12,6 +12,7 @@
namespace ZendServiceTest\Apple\Apns;
+use PHPUnit\Framework\TestCase;
use ZendServiceTest\Apple\Apns\TestAsset\MessageClient;
use ZendService\Apple\Apns\Message;
use ZendService\Apple\Apns\Response\Message as MessageResponse;
@@ -24,7 +25,7 @@
* @group ZendService_Apple
* @group ZendService_Apple_Apns
*/
-class MessageClientTest extends \PHPUnit_Framework_TestCase
+class MessageClientTest extends TestCase
{
public function setUp()
{
@@ -42,26 +43,26 @@ protected function setupValidBase()
public function testConnectThrowsExceptionOnInvalidEnvironment()
{
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException('InvalidArgumentException');
$this->apns->open(5, __DIR__ . '/TestAsset/certificate.pem');
}
public function testSetCertificateThrowsExceptionOnNonString()
{
- $this->setExpectedException('InvalidArgumentException');
- $this->apns->open(MessageClient::PRODUCTION_URI, array('foo'));
+ $this->expectException('InvalidArgumentException');
+ $this->apns->open(MessageClient::PRODUCTION_URI, ['foo']);
}
public function testSetCertificateThrowsExceptionOnMissingFile()
{
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException('InvalidArgumentException');
$this->apns->open(MessageClient::PRODUCTION_URI, 'foo');
}
public function testSetCertificatePassphraseThrowsExceptionOnNonString()
{
- $this->setExpectedException('InvalidArgumentException');
- $this->apns->open(MessageClient::PRODUCTION_URI, __DIR__ . '/TestAsset/certificate.pem', array('foo'));
+ $this->expectException('InvalidArgumentException');
+ $this->apns->open(MessageClient::PRODUCTION_URI, __DIR__ . '/TestAsset/certificate.pem', ['foo']);
}
public function testOpen()
@@ -80,7 +81,7 @@ public function testClose()
public function testOpenWhenAlreadyOpenThrowsException()
{
- $this->setExpectedException('RuntimeException');
+ $this->expectException('RuntimeException');
$this->apns->open(MessageClient::SANDBOX_URI, __DIR__ . '/TestAsset/certificate.pem');
$this->apns->open(MessageClient::SANDBOX_URI, __DIR__ . '/TestAsset/certificate.pem');
}
diff --git a/tests/ZendService/Apple/Apns/MessageTest.php b/test/Apns/MessageTest.php
similarity index 70%
rename from tests/ZendService/Apple/Apns/MessageTest.php
rename to test/Apns/MessageTest.php
index 3e829d8..278a078 100644
--- a/tests/ZendService/Apple/Apns/MessageTest.php
+++ b/test/Apns/MessageTest.php
@@ -1,15 +1,14 @@
setExpectedException('InvalidArgumentException');
- $this->message->setAlert(array());
+ $this->expectException(InvalidArgumentException::class);
+ $this->message->setAlert([]);
}
public function testSetAlertThrowsExceptionOnActionLocKeyNonString()
{
- $this->setExpectedException('InvalidArgumentException');
- $this->alert->setActionLocKey(array());
+ $this->expectException(InvalidArgumentException::class);
+ $this->alert->setActionLocKey([]);
}
public function testSetAlertThrowsExceptionOnLocKeyNonString()
{
- $this->setExpectedException('InvalidArgumentException');
- $this->alert->setLocKey(array());
+ $this->expectException(InvalidArgumentException::class);
+ $this->alert->setLocKey([]);
}
public function testSetAlertThrowsExceptionOnLaunchImageNonString()
{
- $this->setExpectedException('InvalidArgumentException');
- $this->alert->setLaunchImage(array());
+ $this->expectException(InvalidArgumentException::class);
+ $this->alert->setLaunchImage([]);
}
public function testSetAlertThrowsExceptionOnTitleNonString()
{
- $this->setExpectedException('InvalidArgumentException');
- $this->alert->setTitle(array());
+ $this->expectException(InvalidArgumentException::class);
+ $this->alert->setTitle([]);
}
public function testSetAlertThrowsExceptionOnTitleLocKeyNonString()
{
- $this->setExpectedException('InvalidArgumentException');
- $this->alert->setTitleLocKey(array());
+ $this->expectException(InvalidArgumentException::class);
+ $this->alert->setTitleLocKey([]);
}
public function testSetBadgeReturnsCorrectNumber()
@@ -86,7 +85,7 @@ public function testSetBadgeReturnsCorrectNumber()
public function testSetBadgeNonNumericThrowsException()
{
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->message->setBadge('string!');
}
@@ -105,7 +104,7 @@ public function testSetExpireReturnsInteger()
public function testSetExpireNonNumericThrowsException()
{
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->message->setExpire('sting!');
}
@@ -118,13 +117,13 @@ public function testSetSoundReturnsString()
public function testSetSoundThrowsExceptionOnNonScalar()
{
- $this->setExpectedException('InvalidArgumentException');
- $this->message->setSound(array());
+ $this->expectException(InvalidArgumentException::class);
+ $this->message->setSound([]);
}
public function testSetSoundThrowsExceptionOnNonString()
{
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->message->setSound(12345);
}
@@ -135,7 +134,7 @@ public function testSetSoundThrowsExceptionOnNonString()
*/
public function testSetMutableContentThrowsExceptionOnNonIntegerOneAndNull($value)
{
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->message->setMutableContent($value);
}
@@ -144,16 +143,16 @@ public function testSetMutableContentThrowsExceptionOnNonIntegerOneAndNull($valu
*/
public function provideSetMutableContentThrowsExceptionOnNonIntegerOneOrNullData()
{
- return array(
- 'unsupported positive integer' => array('value' => 2),
- 'zero integer' => array('value' => 0),
- 'negative integer' => array('value' => -1),
- 'boolean' => array('value' => true),
- 'string' => array('value' => 'any string'),
- 'float' => array('value' => 123.12),
- 'array' => array('value' => array()),
- 'object' => array('value' => new stdClass()),
- );
+ return [
+ 'unsupported positive integer' => ['value' => 2],
+ 'zero integer' => ['value' => 0],
+ 'negative integer' => ['value' => -1],
+ 'boolean' => ['value' => true],
+ 'string' => ['value' => 'any string'],
+ 'float' => ['value' => 123.12],
+ 'array' => ['value' => []],
+ 'object' => ['value' => new stdClass()],
+ ];
}
public function testSetMutableContentResultsInCorrectPayloadWithIntegerValue()
@@ -174,7 +173,7 @@ public function testSetMutableContentResultsInCorrectPayloadWithNullValue()
public function testSetContentAvailableThrowsExceptionOnNonInteger()
{
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->message->setContentAvailable("string");
}
@@ -202,26 +201,26 @@ public function testSetCategoryReturnsString()
public function testSetCategoryThrowsExceptionOnNonScalar()
{
- $this->setExpectedException('InvalidArgumentException');
- $this->message->setCategory(array());
+ $this->expectException(InvalidArgumentException::class);
+ $this->message->setCategory([]);
}
public function testSetCategoryThrowsExceptionOnNonString()
{
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
$this->message->setCategory(12345);
}
public function testSetUrlArgsReturnsString()
{
- $urlArgs = array('path/to/somewhere');
+ $urlArgs = ['path/to/somewhere'];
$this->message->setUrlArgs($urlArgs);
$this->assertEquals($urlArgs, $this->message->getUrlArgs());
}
public function testSetCustomData()
{
- $data = array('key' => 'val', 'key2' => array(1, 2, 3, 4, 5));
+ $data = ['key' => 'val', 'key2' => [1, 2, 3, 4, 5]];
$this->message->setCustom($data);
$this->assertEquals($data, $this->message->getCustom());
}
@@ -232,21 +231,21 @@ public function testAlertConstructor()
'Foo wants to play Bar!',
'PLAY',
'GAME_PLAY_REQUEST_FORMAT',
- array('Foo', 'Baz'),
+ ['Foo', 'Baz'],
'Default.png',
'Alert',
'ALERT',
- array('Foo', 'Baz')
+ ['Foo', 'Baz']
);
$this->assertEquals('Foo wants to play Bar!', $alert->getBody());
$this->assertEquals('PLAY', $alert->getActionLocKey());
$this->assertEquals('GAME_PLAY_REQUEST_FORMAT', $alert->getLocKey());
- $this->assertEquals(array('Foo', 'Baz'), $alert->getLocArgs());
+ $this->assertEquals(['Foo', 'Baz'], $alert->getLocArgs());
$this->assertEquals('Default.png', $alert->getLaunchImage());
$this->assertEquals('Alert', $alert->getTitle());
$this->assertEquals('ALERT', $alert->getTitleLocKey());
- $this->assertEquals(array('Foo', 'Baz'), $alert->getTitleLocArgs());
+ $this->assertEquals(['Foo', 'Baz'], $alert->getTitleLocArgs());
}
public function testAlertJsonPayload()
@@ -255,11 +254,11 @@ public function testAlertJsonPayload()
'Foo wants to play Bar!',
'PLAY',
'GAME_PLAY_REQUEST_FORMAT',
- array('Foo', 'Baz'),
+ ['Foo', 'Baz'],
'Default.png',
'Alert',
'ALERT',
- array('Foo', 'Baz')
+ ['Foo', 'Baz']
);
$payload = $alert->getPayload();
@@ -289,30 +288,46 @@ public function testPayloadJsonFormedCorrectly()
$this->message->setExpire(100);
$this->message->setToken('0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef');
$payload = $this->message->getPayload();
- $this->assertEquals($payload, array('aps' => array('alert' => 'hi=привет')));
+ $this->assertEquals($payload, ['aps' => ['alert' => 'hi=привет']]);
if (defined('JSON_UNESCAPED_UNICODE')) {
$payloadJson = json_encode($payload, JSON_UNESCAPED_UNICODE);
$this->assertEquals($payloadJson, '{"aps":{"alert":"hi=привет"}}');
$length = 35; // 23 + (2 * 6) because UTF-8 (Russian) "привет" contains 2 bytes per letter
- $result = pack('CNNnH*', 1, $this->message->getId(), $this->message->getExpire(), 32, $this->message->getToken())
- . pack('n', $length)
- . $payloadJson;
+ $result =
+ pack(
+ 'CNNnH*',
+ 1,
+ $this->message->getId(),
+ $this->message->getExpire(),
+ 32,
+ $this->message->getToken()
+ )
+ . pack('n', $length)
+ . $payloadJson;
$this->assertEquals($this->message->getPayloadJson(), $result);
} else {
$payloadJson = JsonEncoder::encode($payload);
$this->assertEquals($payloadJson, '{"aps":{"alert":"hi=\u043f\u0440\u0438\u0432\u0435\u0442"}}');
- $length = 59; // (23 + (6 * 6) because UTF-8 (Russian) "привет" converts into 6 bytes per letter constructions
- $result = pack('CNNnH*', 1, $this->message->getId(), $this->message->getExpire(), 32, $this->message->getToken())
- . pack('n', $length)
- . $payloadJson;
+ $length = 59; // (23 + (6 * 6) because UTF-8 (Russian) "привет" converts into 6 bytes/letter
+ $result =
+ pack(
+ 'CNNnH*',
+ 1,
+ $this->message->getId(),
+ $this->message->getExpire(),
+ 32,
+ $this->message->getToken()
+ )
+ . pack('n', $length)
+ . $payloadJson;
$this->assertEquals($this->message->getPayloadJson(), $result);
}
}
public function testCustomDataPayloadIncludesEmptyApsObject()
{
- $data = array('custom' => 'data');
- $expected = array_merge($data, array('aps' => (object) array()));
+ $data = ['custom' => 'data'];
+ $expected = array_merge($data, ['aps' => (object) []]);
$this->message->setCustom($data);
$payload = $this->message->getPayload();
diff --git a/tests/ZendService/Apple/Apns/TestAsset/FeedbackClient.php b/test/Apns/TestAsset/FeedbackClient.php
similarity index 96%
rename from tests/ZendService/Apple/Apns/TestAsset/FeedbackClient.php
rename to test/Apns/TestAsset/FeedbackClient.php
index 8242cc5..8952db2 100644
--- a/tests/ZendService/Apple/Apns/TestAsset/FeedbackClient.php
+++ b/test/Apns/TestAsset/FeedbackClient.php
@@ -81,7 +81,7 @@ protected function connect($host, array $ssl)
*/
protected function read($length = 1024)
{
- if (!$this->isConnected()) {
+ if (! $this->isConnected()) {
throw new Exception\RuntimeException('You must open the connection prior to reading data');
}
$ret = substr($this->readResponse, 0, $length);
@@ -98,7 +98,7 @@ protected function read($length = 1024)
*/
protected function write($payload)
{
- if (!$this->isConnected()) {
+ if (! $this->isConnected()) {
throw new Exception\RuntimeException('You must open the connection prior to writing data');
}
$ret = $this->writeResponse;
diff --git a/tests/ZendService/Apple/Apns/TestAsset/MessageClient.php b/test/Apns/TestAsset/MessageClient.php
similarity index 96%
rename from tests/ZendService/Apple/Apns/TestAsset/MessageClient.php
rename to test/Apns/TestAsset/MessageClient.php
index d6317c0..31cd361 100644
--- a/tests/ZendService/Apple/Apns/TestAsset/MessageClient.php
+++ b/test/Apns/TestAsset/MessageClient.php
@@ -81,7 +81,7 @@ protected function connect($host, array $ssl)
*/
protected function read($length = 1024)
{
- if (!$this->isConnected()) {
+ if (! $this->isConnected()) {
throw new Exception\RuntimeException('You must open the connection prior to reading data');
}
$ret = substr($this->readResponse, 0, $length);
@@ -98,7 +98,7 @@ protected function read($length = 1024)
*/
protected function write($payload)
{
- if (!$this->isConnected()) {
+ if (! $this->isConnected()) {
throw new Exception\RuntimeException('You must open the connection prior to writing data');
}
$ret = $this->writeResponse;
diff --git a/tests/ZendService/Apple/Apns/TestAsset/certificate.pem b/test/Apns/TestAsset/certificate.pem
similarity index 100%
rename from tests/ZendService/Apple/Apns/TestAsset/certificate.pem
rename to test/Apns/TestAsset/certificate.pem
diff --git a/tests/.gitignore b/tests/.gitignore
deleted file mode 100755
index 902db60..0000000
--- a/tests/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-phpunit.xml
-TestConfiguration.php
diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php
deleted file mode 100755
index 2bebec0..0000000
--- a/tests/Bootstrap.php
+++ /dev/null
@@ -1,93 +0,0 @@
-addDirectoryToWhitelist($zfCoreLibrary . '/' . $lastArg);
- } elseif (is_file($zfCoreTests . '/' . $lastArg)) {
- $codeCoverageFilter->addDirectoryToWhitelist(dirname($zfCoreLibrary . '/' . $lastArg));
- } else {
- $codeCoverageFilter->addDirectoryToWhitelist($zfCoreLibrary);
- }
-
- /*
- * Omit from code coverage reports the contents of the tests directory
- */
- $codeCoverageFilter->addDirectoryToBlacklist($zfCoreTests, '');
- $codeCoverageFilter->addDirectoryToBlacklist(PEAR_INSTALL_DIR, '');
- $codeCoverageFilter->addDirectoryToBlacklist(PHP_LIBDIR, '');
-
- unset($codeCoverageFilter);
-}
-
-/**
- * Start output buffering, if enabled
- */
-if (defined('TESTS_ZEND_OB_ENABLED') && constant('TESTS_ZEND_OB_ENABLED')) {
- ob_start();
-}
-
-/*
- * Unset global variables that are no longer needed.
- */
-unset($zfRoot, $zfCoreLibrary, $zfCoreTests, $path);
diff --git a/tests/TestConfiguration.php.dist b/tests/TestConfiguration.php.dist
deleted file mode 100755
index 536498f..0000000
--- a/tests/TestConfiguration.php.dist
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
- ./ZendService
-
-
-
-
-
- disable
-
-
-