update v1.0.7.9 R.C.
This is a Release Candidate. We are still testing.
This commit is contained in:
2
vendor/zendframework/zendservice-google-gcm/tests/.gitignore
vendored
Normal file
2
vendor/zendframework/zendservice-google-gcm/tests/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
phpunit.xml
|
||||
TestConfiguration.php
|
92
vendor/zendframework/zendservice-google-gcm/tests/Bootstrap.php
vendored
Normal file
92
vendor/zendframework/zendservice-google-gcm/tests/Bootstrap.php
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @package Zend
|
||||
*/
|
||||
|
||||
/*
|
||||
* Set error reporting to the level to which Zend Framework code must comply.
|
||||
*/
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
|
||||
$phpUnitVersion = PHPUnit_Runner_Version::id();
|
||||
if ('@package_version@' !== $phpUnitVersion && version_compare($phpUnitVersion, '3.5.0', '<')) {
|
||||
echo 'This version of PHPUnit (' . PHPUnit_Runner_Version::id() . ') is not supported in Zend Framework 2.x unit tests.' . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
unset($phpUnitVersion);
|
||||
|
||||
/*
|
||||
* Determine the root, library, and tests directories of the framework
|
||||
* distribution.
|
||||
*/
|
||||
$zfRoot = realpath(dirname(__DIR__));
|
||||
$zfCoreLibrary = "$zfRoot/library";
|
||||
$zfCoreTests = "$zfRoot/tests";
|
||||
|
||||
/*
|
||||
* Prepend the Zend Framework library/ and tests/ directories to the
|
||||
* include_path. This allows the tests to run out of the box and helps prevent
|
||||
* loading other copies of the framework code and tests that would supersede
|
||||
* this copy.
|
||||
*/
|
||||
$path = array(
|
||||
$zfCoreLibrary,
|
||||
$zfCoreTests,
|
||||
get_include_path(),
|
||||
);
|
||||
set_include_path(implode(PATH_SEPARATOR, $path));
|
||||
|
||||
/**
|
||||
* Setup autoloading
|
||||
*/
|
||||
include __DIR__ . '/_autoload.php';
|
||||
|
||||
/*
|
||||
* Load the user-defined test configuration file, if it exists; otherwise, load
|
||||
* the default configuration.
|
||||
*/
|
||||
if (is_readable($zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php')) {
|
||||
require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php';
|
||||
} else {
|
||||
require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php.dist';
|
||||
}
|
||||
|
||||
if (defined('TESTS_GENERATE_REPORT') && TESTS_GENERATE_REPORT === true) {
|
||||
$codeCoverageFilter = PHP_CodeCoverage_Filter::getInstance();
|
||||
|
||||
$lastArg = end($_SERVER['argv']);
|
||||
if (is_dir($zfCoreTests . '/' . $lastArg)) {
|
||||
$codeCoverageFilter->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);
|
45
vendor/zendframework/zendservice-google-gcm/tests/TestConfiguration.php.dist
vendored
Normal file
45
vendor/zendframework/zendservice-google-gcm/tests/TestConfiguration.php.dist
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @package UnitTests
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file defines configuration for running the unit tests for the Zend
|
||||
* Framework. Some tests have dependencies to PHP extensions or databases
|
||||
* which may not necessary installed on the target system. For these cases,
|
||||
* the ability to disable or configure testing is provided below. Tests for
|
||||
* components which should run universally are always run by the master
|
||||
* suite and cannot be disabled.
|
||||
*
|
||||
* Do not edit this file. Instead, copy this file to TestConfiguration.php,
|
||||
* and edit the new file. Never commit passwords to the source code repository.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Use the notation:
|
||||
*
|
||||
* defined(...) || define(...);
|
||||
*
|
||||
* This ensures that, when a test is marked to run in a separate process,
|
||||
* PHP will not complain of a constant already being defined.
|
||||
*/
|
||||
|
||||
/**
|
||||
* GENERAL SETTINGS
|
||||
*
|
||||
* OB_ENABLED should be enabled for some tests to check if all functionality
|
||||
* works as expected. Such tests include those for Zend\Soap and Zend\Session,
|
||||
* which require that headers not be sent in order to work.
|
||||
*/
|
||||
defined('TESTS_ZEND_OB_ENABLED') || define('TESTS_ZEND_OB_ENABLED', false);
|
||||
|
||||
/**
|
||||
* PHPUnit Code Coverage / Test Report
|
||||
*/
|
||||
defined('TESTS_GENERATE_REPORT') || define('TESTS_GENERATE_REPORT', false);
|
||||
defined('TESTS_GENERATE_REPORT_TARGET') || define('TESTS_GENERATE_REPORT_TARGET', '/path/to/target');
|
20
vendor/zendframework/zendservice-google-gcm/tests/TestConfiguration.php.travis
vendored
Normal file
20
vendor/zendframework/zendservice-google-gcm/tests/TestConfiguration.php.travis
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @package UnitTests
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file defines specific configuration that differs from the standard configuration
|
||||
* for running the unit tests with Travis-CI (http://www.travis-ci.org)
|
||||
*
|
||||
* See TestConfiguration.php.dist to get more details.
|
||||
*
|
||||
* Never commit passwords to the source code repository.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/TestConfiguration.php.dist';
|
217
vendor/zendframework/zendservice-google-gcm/tests/ZendService/Google/Gcm/ClientTest.php
vendored
Normal file
217
vendor/zendframework/zendservice-google-gcm/tests/ZendService/Google/Gcm/ClientTest.php
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @category ZendService
|
||||
* @package ZendService_Google
|
||||
* @subpackage UnitTests
|
||||
*/
|
||||
|
||||
namespace ZendServiceTest\Google\Gcm;
|
||||
|
||||
use Zend\Http\Client\Adapter\Test;
|
||||
use Zend\Http\Client as HttpClient;
|
||||
use ZendService\Google\Gcm\Client;
|
||||
use ZendService\Google\Gcm\Message;
|
||||
use ZendService\Google\Gcm\Response;
|
||||
|
||||
/**
|
||||
* @category ZendService
|
||||
* @package ZendService_Google
|
||||
* @subpackage UnitTests
|
||||
* @group ZendService
|
||||
* @group ZendService_Google
|
||||
* @group ZendService_Google_Gcm
|
||||
*/
|
||||
class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $httpAdapter;
|
||||
protected $httpClient;
|
||||
protected $gcmClient;
|
||||
protected $message;
|
||||
|
||||
protected function _createJSONResponse($id, $success, $failure, $ids, $results)
|
||||
{
|
||||
return json_encode(array(
|
||||
'multicast_id' => $id,
|
||||
'success' => $success,
|
||||
'failure' => $failure,
|
||||
'canonical_ids' => $ids,
|
||||
'results' => $results
|
||||
));
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->httpClient = new HttpClient();
|
||||
$this->httpAdapter = new Test();
|
||||
$this->httpClient->setAdapter($this->httpAdapter);
|
||||
$this->gcmClient = new Client();
|
||||
$this->gcmClient->setHttpClient($this->httpClient);
|
||||
$this->gcmClient->setApiKey('testing');
|
||||
$this->message = new Message();
|
||||
$this->message->addRegistrationId('testing');
|
||||
$this->message->addData('testKey', 'testValue');
|
||||
}
|
||||
|
||||
public function testSetApiKeyThrowsExceptionOnNonString()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->gcmClient->setApiKey(array());
|
||||
}
|
||||
|
||||
public function testSetApiKey()
|
||||
{
|
||||
$key = 'a-login-token';
|
||||
$this->gcmClient->setApiKey($key);
|
||||
$this->assertEquals($key, $this->gcmClient->getApiKey());
|
||||
}
|
||||
|
||||
public function testGetHttpClientReturnsDefault()
|
||||
{
|
||||
$gcm = new Client();
|
||||
$this->assertEquals('Zend\Http\Client', get_class($gcm->getHttpClient()));
|
||||
$this->assertTrue($gcm->getHttpClient() instanceof HttpClient);
|
||||
}
|
||||
|
||||
public function testSetHttpClient()
|
||||
{
|
||||
$client = new HttpClient();
|
||||
$this->gcmClient->setHttpClient($client);
|
||||
$this->assertEquals($client, $this->gcmClient->getHttpClient());
|
||||
}
|
||||
|
||||
public function testSendThrowsExceptionWhenServiceUnavailable()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
$this->httpAdapter->setResponse('HTTP/1.1 503 Service Unavailable' . "\r\n\r\n");
|
||||
$this->gcmClient->send($this->message);
|
||||
}
|
||||
|
||||
public function testSendThrowsExceptionWhenServerUnavailable()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
$this->httpAdapter->setResponse('HTTP/1.1 500 Internal Server Error' . "\r\n\r\n");
|
||||
$this->gcmClient->send($this->message);
|
||||
}
|
||||
|
||||
public function testSendThrowsExceptionWhenInvalidAuthToken()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
$this->httpAdapter->setResponse('HTTP/1.1 401 Unauthorized' . "\r\n\r\n");
|
||||
$this->gcmClient->send($this->message);
|
||||
}
|
||||
|
||||
public function testSendThrowsExceptionWhenInvalidPayload()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
$this->httpAdapter->setResponse('HTTP/1.1 400 Bad Request' . "\r\n\r\n");
|
||||
$this->gcmClient->send($this->message);
|
||||
}
|
||||
|
||||
public function testSendResultInvalidRegistrationId()
|
||||
{
|
||||
$body = $this->_createJSONResponse(101, 0, 1, 0, array(array('error' => 'InvalidRegistration')));
|
||||
$this->httpAdapter->setResponse(
|
||||
'HTTP/1.1 200 OK' . "\r\n" .
|
||||
'Context-Type: text/html' . "\r\n\r\n" .
|
||||
$body
|
||||
);
|
||||
$response = $this->gcmClient->send($this->message);
|
||||
$result = $response->getResults();
|
||||
$result = array_shift($result);
|
||||
$this->assertEquals('InvalidRegistration', $result['error']);
|
||||
$this->assertEquals(0, $response->getSuccessCount());
|
||||
$this->assertEquals(0, $response->getCanonicalCount());
|
||||
$this->assertEquals(1, $response->getFailureCount());
|
||||
}
|
||||
|
||||
public function testSendResultMismatchSenderId()
|
||||
{
|
||||
$body = $this->_createJSONResponse(101, 0, 1, 0, array(array('error' => 'MismatchSenderId')));
|
||||
$this->httpAdapter->setResponse(
|
||||
'HTTP/1.1 200 OK' . "\r\n" .
|
||||
'Context-Type: text/html' . "\r\n\r\n" .
|
||||
$body
|
||||
);
|
||||
$response = $this->gcmClient->send($this->message);
|
||||
$result = $response->getResults();
|
||||
$result = array_shift($result);
|
||||
$this->assertEquals('MismatchSenderId', $result['error']);
|
||||
$this->assertEquals(0, $response->getSuccessCount());
|
||||
$this->assertEquals(0, $response->getCanonicalCount());
|
||||
$this->assertEquals(1, $response->getFailureCount());
|
||||
}
|
||||
|
||||
public function testSendResultNotRegistered()
|
||||
{
|
||||
$body = $this->_createJSONResponse(101, 0, 1, 0, array(array('error' => 'NotRegistered')));
|
||||
$this->httpAdapter->setResponse(
|
||||
'HTTP/1.1 200 OK' . "\r\n" .
|
||||
'Context-Type: text/html' . "\r\n\r\n" .
|
||||
$body
|
||||
);
|
||||
$response = $this->gcmClient->send($this->message);
|
||||
$result = $response->getResults();
|
||||
$result = array_shift($result);
|
||||
$this->assertEquals('NotRegistered', $result['error']);
|
||||
$this->assertEquals(0, $response->getSuccessCount());
|
||||
$this->assertEquals(0, $response->getCanonicalCount());
|
||||
$this->assertEquals(1, $response->getFailureCount());
|
||||
}
|
||||
|
||||
public function testSendResultMessageTooBig()
|
||||
{
|
||||
$body = $this->_createJSONResponse(101, 0, 1, 0, array(array('error' => 'MessageTooBig')));
|
||||
$this->httpAdapter->setResponse(
|
||||
'HTTP/1.1 200 OK' . "\r\n" .
|
||||
'Context-Type: text/html' . "\r\n\r\n" .
|
||||
$body
|
||||
);
|
||||
$response = $this->gcmClient->send($this->message);
|
||||
$result = $response->getResults();
|
||||
$result = array_shift($result);
|
||||
$this->assertEquals('MessageTooBig', $result['error']);
|
||||
$this->assertEquals(0, $response->getSuccessCount());
|
||||
$this->assertEquals(0, $response->getCanonicalCount());
|
||||
$this->assertEquals(1, $response->getFailureCount());
|
||||
}
|
||||
|
||||
public function testSendResultSuccessful()
|
||||
{
|
||||
$body = $this->_createJSONResponse(101, 1, 0, 0, array(array('message_id' => '1:2342')));
|
||||
$this->httpAdapter->setResponse(
|
||||
'HTTP/1.1 200 OK' . "\r\n" .
|
||||
'Context-Type: text/html' . "\r\n\r\n" .
|
||||
$body
|
||||
);
|
||||
$response = $this->gcmClient->send($this->message);
|
||||
$result = $response->getResults();
|
||||
$result = array_shift($result);
|
||||
$this->assertEquals('1:2342', $result['message_id']);
|
||||
$this->assertEquals(1, $response->getSuccessCount());
|
||||
$this->assertEquals(0, $response->getCanonicalCount());
|
||||
$this->assertEquals(0, $response->getFailureCount());
|
||||
}
|
||||
|
||||
public function testSendResultSuccessfulWithRegistrationId()
|
||||
{
|
||||
$body = $this->_createJSONResponse(101, 1, 0, 1, array(array('message_id' => '1:2342', 'registration_id' => 'testfoo')));
|
||||
$this->httpAdapter->setResponse(
|
||||
'HTTP/1.1 200 OK' . "\r\n" .
|
||||
'Context-Type: text/html' . "\r\n\r\n" .
|
||||
$body
|
||||
);
|
||||
$response = $this->gcmClient->send($this->message);
|
||||
$result = $response->getResults();
|
||||
$result = array_shift($result);
|
||||
$this->assertEquals('1:2342', $result['message_id']);
|
||||
$this->assertEquals('testfoo', $result['registration_id']);
|
||||
$this->assertEquals(1, $response->getSuccessCount());
|
||||
$this->assertEquals(1, $response->getCanonicalCount());
|
||||
$this->assertEquals(0, $response->getFailureCount());
|
||||
}
|
||||
}
|
159
vendor/zendframework/zendservice-google-gcm/tests/ZendService/Google/Gcm/MessageTest.php
vendored
Normal file
159
vendor/zendframework/zendservice-google-gcm/tests/ZendService/Google/Gcm/MessageTest.php
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @category ZendService
|
||||
* @package ZendService_Google
|
||||
* @subpackage UnitTests
|
||||
*/
|
||||
|
||||
namespace ZendServiceTest\Google\Gcm;
|
||||
|
||||
use ZendService\Google\Gcm\Message;
|
||||
|
||||
/**
|
||||
* @category ZendService
|
||||
* @package ZendService_Google
|
||||
* @subpackage UnitTests
|
||||
* @group ZendService
|
||||
* @group ZendService_Google
|
||||
* @group ZendService_Google_Gcm
|
||||
*/
|
||||
class MessageTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $validRegistrationIds = array('1234567890', '0987654321');
|
||||
protected $validData = array('key' => 'value', 'key2' => array('value'));
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->m = new Message();
|
||||
}
|
||||
|
||||
public function testExpectedRegistrationIdBehavior()
|
||||
{
|
||||
$this->assertEquals($this->m->getRegistrationIds(), array());
|
||||
$this->assertNotContains('registration_ids', $this->m->toJson());
|
||||
$this->m->setRegistrationIds($this->validRegistrationIds);
|
||||
$this->assertEquals($this->m->getRegistrationIds(), $this->validRegistrationIds);
|
||||
foreach ($this->validRegistrationIds as $id) {
|
||||
$this->m->addRegistrationId($id);
|
||||
}
|
||||
$this->assertEquals($this->m->getRegistrationIds(), $this->validRegistrationIds);
|
||||
$this->assertContains('registration_ids', $this->m->toJson());
|
||||
$this->m->clearRegistrationIds();
|
||||
$this->assertEquals($this->m->getRegistrationIds(), array());
|
||||
$this->assertNotContains('registration_ids', $this->m->toJson());
|
||||
$this->m->addRegistrationId('1029384756');
|
||||
$this->assertEquals($this->m->getRegistrationIds(), array('1029384756'));
|
||||
$this->assertContains('registration_ids', $this->m->toJson());
|
||||
}
|
||||
|
||||
public function testInvalidRegistrationIdThrowsException()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->m->addRegistrationId(array('1234'));
|
||||
}
|
||||
|
||||
public function testExpectedCollapseKeyBehavior()
|
||||
{
|
||||
$this->assertEquals($this->m->getCollapseKey(), null);
|
||||
$this->assertNotContains('collapse_key', $this->m->toJson());
|
||||
$this->m->setCollapseKey('my collapse key');
|
||||
$this->assertEquals($this->m->getCollapseKey(), 'my collapse key');
|
||||
$this->assertContains('collapse_key', $this->m->toJson());
|
||||
$this->m->setCollapseKey(null);
|
||||
$this->assertEquals($this->m->getCollapseKey(), null);
|
||||
$this->assertNotContains('collapse_key', $this->m->toJson());
|
||||
}
|
||||
|
||||
public function testInvalidCollapseKeyThrowsException()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->m->setCollapseKey(array('1234'));
|
||||
}
|
||||
|
||||
public function testExpectedDataBehavior()
|
||||
{
|
||||
$this->assertEquals($this->m->getData(), array());
|
||||
$this->assertNotContains('data', $this->m->toJson());
|
||||
$this->m->setData($this->validData);
|
||||
$this->assertEquals($this->m->getData(), $this->validData);
|
||||
$this->assertContains('data', $this->m->toJson());
|
||||
$this->m->clearData();
|
||||
$this->assertEquals($this->m->getData(), array());
|
||||
$this->assertNotContains('data', $this->m->toJson());
|
||||
$this->m->addData('mykey', 'myvalue');
|
||||
$this->assertEquals($this->m->getData(), array('mykey' => 'myvalue'));
|
||||
$this->assertContains('data', $this->m->toJson());
|
||||
}
|
||||
|
||||
public function testInvalidDataThrowsException()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->m->addData(array('1234'), 'value');
|
||||
}
|
||||
|
||||
public function testDuplicateDataKeyThrowsException()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
$this->m->setData($this->validData);
|
||||
$this->m->addData('key', 'value');
|
||||
}
|
||||
|
||||
public function testExpectedDelayWhileIdleBehavior()
|
||||
{
|
||||
$this->assertEquals($this->m->getDelayWhileIdle(), false);
|
||||
$this->assertNotContains('delay_while_idle', $this->m->toJson());
|
||||
$this->m->setDelayWhileIdle(true);
|
||||
$this->assertEquals($this->m->getDelayWhileIdle(), true);
|
||||
$this->assertContains('delay_while_idle', $this->m->toJson());
|
||||
$this->m->setDelayWhileIdle(false);
|
||||
$this->assertEquals($this->m->getDelayWhileIdle(), false);
|
||||
$this->assertNotContains('delay_while_idle', $this->m->toJson());
|
||||
}
|
||||
|
||||
public function testExpectedTimeToLiveBehavior()
|
||||
{
|
||||
$this->assertEquals($this->m->getTimeToLive(), 2419200);
|
||||
$this->assertNotContains('time_to_live', $this->m->toJson());
|
||||
$this->m->setTimeToLive(12345);
|
||||
$this->assertEquals($this->m->getTimeToLive(), 12345);
|
||||
$this->assertContains('time_to_live', $this->m->toJson());
|
||||
$this->m->setTimeToLive(2419200);
|
||||
$this->assertEquals($this->m->getTimeToLive(), 2419200);
|
||||
$this->assertNotContains('time_to_live', $this->m->toJson());
|
||||
}
|
||||
|
||||
public function testExpectedRestrictedPackageBehavior()
|
||||
{
|
||||
$this->assertEquals($this->m->getRestrictedPackageName(), null);
|
||||
$this->assertNotContains('restricted_package_name', $this->m->toJson());
|
||||
$this->m->setRestrictedPackageName('my.package.name');
|
||||
$this->assertEquals($this->m->getRestrictedPackageName(), 'my.package.name');
|
||||
$this->assertContains('restricted_package_name', $this->m->toJson());
|
||||
$this->m->setRestrictedPackageName(null);
|
||||
$this->assertEquals($this->m->getRestrictedPackageName(), null);
|
||||
$this->assertNotContains('restricted_package_name', $this->m->toJson());
|
||||
}
|
||||
|
||||
public function testInvalidRestrictedPackageThrowsException()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->m->setRestrictedPackageName(array('1234'));
|
||||
}
|
||||
|
||||
public function testExpectedDryRunBehavior()
|
||||
{
|
||||
$this->assertEquals($this->m->getDryRun(), false);
|
||||
$this->assertNotContains('dry_run', $this->m->toJson());
|
||||
$this->m->setDryRun(true);
|
||||
$this->assertEquals($this->m->getDryRun(), true);
|
||||
$this->assertContains('dry_run', $this->m->toJson());
|
||||
$this->m->setDryRun(false);
|
||||
$this->assertEquals($this->m->getDryRun(), false);
|
||||
$this->assertNotContains('dry_run', $this->m->toJson());
|
||||
}
|
||||
}
|
102
vendor/zendframework/zendservice-google-gcm/tests/ZendService/Google/Gcm/ResponseTest.php
vendored
Normal file
102
vendor/zendframework/zendservice-google-gcm/tests/ZendService/Google/Gcm/ResponseTest.php
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @category ZendService
|
||||
* @package ZendService_Google
|
||||
* @subpackage UnitTests
|
||||
*/
|
||||
|
||||
namespace ZendServiceTest\Google\Gcm;
|
||||
|
||||
use ZendService\Google\Gcm\Message;
|
||||
use ZendService\Google\Gcm\Response;
|
||||
|
||||
/**
|
||||
* @category ZendService
|
||||
* @package ZendService_Google
|
||||
* @subpackage UnitTests
|
||||
* @group ZendService
|
||||
* @group ZendService_Google
|
||||
* @group ZendService_Google_Gcm
|
||||
*/
|
||||
class ResponseTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$this->m = new Message();
|
||||
}
|
||||
|
||||
public function testConstructorExpectedBehavior()
|
||||
{
|
||||
$response = new Response();
|
||||
$this->assertNull($response->getResponse());
|
||||
$this->assertNull($response->getMessage());
|
||||
|
||||
$message = new Message();
|
||||
$response = new Response(null, $message);
|
||||
$this->assertEquals($message, $response->getMessage());
|
||||
$this->assertNull($response->getResponse());
|
||||
|
||||
$message = new Message();
|
||||
$responseArray = array(
|
||||
'results' => array(
|
||||
array('message_id' => '1:1234'),
|
||||
),
|
||||
'success' => 1,
|
||||
'failure' => 0,
|
||||
'canonical_ids' => 0,
|
||||
'multicast_id' => 1,
|
||||
);
|
||||
$response = new Response($responseArray, $message);
|
||||
$this->assertEquals($responseArray, $response->getResponse());
|
||||
$this->assertEquals($message, $response->getMessage());
|
||||
}
|
||||
|
||||
public function testInvalidConstructorThrowsException()
|
||||
{
|
||||
$this->setExpectedException('PHPUnit_Framework_Error');
|
||||
$response = new Response('{bad');
|
||||
}
|
||||
|
||||
public function testMessageExpectedBehavior()
|
||||
{
|
||||
$message = new Message();
|
||||
$response = new Response();
|
||||
$response->setMessage($message);
|
||||
$this->assertEquals($message, $response->getMessage());
|
||||
}
|
||||
|
||||
public function testResponse()
|
||||
{
|
||||
$responseArr = array(
|
||||
'results' => array(
|
||||
array('message_id' => '1:234'),
|
||||
),
|
||||
'success' => 1,
|
||||
'failure' => 0,
|
||||
'canonical_ids' => 0,
|
||||
'multicast_id' => '123',
|
||||
);
|
||||
$response = new Response();
|
||||
$response->setResponse($responseArr);
|
||||
$this->assertEquals($responseArr, $response->getResponse());
|
||||
$this->assertEquals(1, $response->getSuccessCount());
|
||||
$this->assertEquals(0, $response->getFailureCount());
|
||||
$this->assertEquals(0, $response->getCanonicalCount());
|
||||
// test results non correlated
|
||||
$expected = array(array('message_id' => '1:234'));
|
||||
$this->assertEquals($expected, $response->getResults());
|
||||
$expected = array(0 => '1:234');
|
||||
$this->assertEquals($expected, $response->getResult(Response::RESULT_MESSAGE_ID));
|
||||
|
||||
$message = new Message();
|
||||
$message->setRegistrationIds(array('ABCDEF'));
|
||||
$response->setMessage($message);
|
||||
$expected = array('ABCDEF' => '1:234');
|
||||
$this->assertEquals($expected, $response->getResult(Response::RESULT_MESSAGE_ID));
|
||||
}
|
||||
}
|
28
vendor/zendframework/zendservice-google-gcm/tests/_autoload.php
vendored
Normal file
28
vendor/zendframework/zendservice-google-gcm/tests/_autoload.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Setup autoloading
|
||||
*/
|
||||
|
||||
if (!file_exists(__DIR__ . '/../vendor/autoload.php')) {
|
||||
throw new RuntimeException('This component has dependencies that are unmet.
|
||||
|
||||
Please install composer (http://getcomposer.org), and run the following
|
||||
command in the root of this project:
|
||||
|
||||
php /path/to/composer.phar install
|
||||
|
||||
After that, you should be able to run tests.');
|
||||
}
|
||||
include_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
spl_autoload_register(function ($class) {
|
||||
if (0 !== strpos($class, 'ZendServiceTest\\')) {
|
||||
return false;
|
||||
}
|
||||
$normalized = str_replace('ZendServiceTest\\', '', $class);
|
||||
$filename = __DIR__ . '/ZendService/' . str_replace(array('\\', '_'), '/', $normalized) . '.php';
|
||||
if (!file_exists($filename)) {
|
||||
return false;
|
||||
}
|
||||
return include_once $filename;
|
||||
});
|
13
vendor/zendframework/zendservice-google-gcm/tests/phpunit.xml.dist
vendored
Normal file
13
vendor/zendframework/zendservice-google-gcm/tests/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<phpunit bootstrap="./Bootstrap.php" colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="ZendService Google Gcm Test Suite">
|
||||
<directory>./ZendService</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<groups>
|
||||
<exclude>
|
||||
<group>disable</group>
|
||||
</exclude>
|
||||
</groups>
|
||||
</phpunit>
|
Reference in New Issue
Block a user