Laravel version update
Laravel version update
This commit is contained in:
@@ -4,13 +4,13 @@ namespace tests\units\Sly\NotificationPusher\Adapter;
|
||||
|
||||
use mageekguy\atoum as Units;
|
||||
use Sly\NotificationPusher\Adapter\Apns as TestedModel;
|
||||
|
||||
use Sly\NotificationPusher\Model\Message as BaseMessage;
|
||||
use Sly\NotificationPusher\Model\Device as BaseDevice;
|
||||
use Sly\NotificationPusher\Collection\DeviceCollection as BaseDeviceCollection;
|
||||
|
||||
use ZendService\Apple\Apns\Message as BaseServiceMessage;
|
||||
use Sly\NotificationPusher\Collection\DeviceCollection;
|
||||
use Sly\NotificationPusher\Model\Device as BaseDevice;
|
||||
use Sly\NotificationPusher\Model\Message as BaseMessage;
|
||||
use Sly\NotificationPusher\Model\Response;
|
||||
use ZendService\Apple\Apns\Client\Message as BaseServiceClient;
|
||||
use ZendService\Apple\Apns\Message as BaseServiceMessage;
|
||||
|
||||
/**
|
||||
* Apns.
|
||||
@@ -42,6 +42,7 @@ class Apns extends Units\Test
|
||||
->and($this->mockClass('\Sly\NotificationPusher\Adapter\Apns', '\Mock'))
|
||||
->and($object = new \Mock\Apns())
|
||||
->and($object->setParameters(['certificate' => 'test.pem', 'passPhrase' => 'test']))
|
||||
->and($object->setResponse(new Response()))
|
||||
->array($object->getParameters())
|
||||
->isNotEmpty()
|
||||
->hasSize(2)
|
||||
@@ -141,22 +142,26 @@ class Apns extends Units\Test
|
||||
|
||||
public function testPush()
|
||||
{
|
||||
$this->if($this->mockGenerator()->orphanize('__construct'))
|
||||
->and($this->mockClass('\Sly\NotificationPusher\Adapter\Apns', '\Mock'))
|
||||
$this->if($this->mockGenerator()->orphanize('__construct')
|
||||
->makeVisible('getOpenedServiceClient')
|
||||
->generate(\Sly\NotificationPusher\Adapter\Apns::class, '\Mock', 'Apns'))
|
||||
->and($object = new \Mock\Apns())
|
||||
->and($object->setResponse(new Response()))
|
||||
|
||||
->and($this->mockClass('\ZendService\Apple\Apns\Response\Message', '\Mock\ZendService', 'Response'))
|
||||
->and($this->mockClass(\ZendService\Apple\Apns\Response\Message::class, '\Mock\ZendService', 'Response'))
|
||||
->and($serviceResponse = new \Mock\ZendService\Response())
|
||||
->and($serviceResponse->getMockController()->getCode = \ZendService\Apple\Apns\Response\Message::RESULT_OK)
|
||||
->and($serviceResponse->getMockController()->getId = 0)
|
||||
|
||||
->and($this->mockGenerator()->orphanize('__construct'))
|
||||
->and($this->mockGenerator()->orphanize('open'))
|
||||
->and($this->mockGenerator()->orphanize('send'))
|
||||
->and($this->mockClass('\ZendService\Apple\Apns\Client\Message', '\Mock\ZendService'))
|
||||
->and($this->mockGenerator()->orphanize('__construct')
|
||||
->orphanize('open')
|
||||
->orphanize('send')
|
||||
->generate(\ZendService\Apple\Apns\Client\Message::class, '\Mock\ZendService'))
|
||||
->and($serviceClient = new \Mock\ZendService\Message())
|
||||
->and($serviceClient->getMockController()->send = new $serviceResponse)
|
||||
->and($serviceClient->getMockController()->send = $serviceResponse)
|
||||
|
||||
->and($this->mockGenerator()->orphanize('__construct'))
|
||||
->and($this->mockClass('\Sly\NotificationPusher\Model\Push', '\Mock'))
|
||||
->and($this->mockClass(\Sly\NotificationPusher\Model\Push::class, '\Mock'))
|
||||
->and($push = new \Mock\Push())
|
||||
->and($push->getMockController()->getMessage = new BaseMessage('Test'))
|
||||
->and($push->getMockController()->getDevices = new BaseDeviceCollection(
|
||||
@@ -165,11 +170,18 @@ class Apns extends Units\Test
|
||||
|
||||
->and($object->getMockController()->getServiceMessageFromOrigin = new BaseServiceMessage())
|
||||
->and($object->getMockController()->getOpenedClient = $serviceClient)
|
||||
->and($this->calling($object)->getOpenedServiceClient = $serviceClient)
|
||||
|
||||
->object($object->push($push))
|
||||
->object($result = $object->push($push))
|
||||
->isInstanceOf('\Sly\NotificationPusher\Collection\DeviceCollection')
|
||||
->hasSize(1)
|
||||
;
|
||||
->boolean($result->count() == 1)
|
||||
->isTrue();
|
||||
}
|
||||
|
||||
public function testCountIsEmpty() {
|
||||
$this->if($dcoll = new DeviceCollection())
|
||||
->boolean($dcoll->isEmpty())
|
||||
->isTrue();
|
||||
}
|
||||
|
||||
public function testFeedback()
|
||||
|
||||
@@ -9,6 +9,7 @@ use Sly\NotificationPusher\Model\Message as BaseMessage;
|
||||
use Sly\NotificationPusher\Model\Device as BaseDevice;
|
||||
use Sly\NotificationPusher\Collection\DeviceCollection as BaseDeviceCollection;
|
||||
|
||||
use Sly\NotificationPusher\Model\Response;
|
||||
use ZendService\Google\Gcm\Client as BaseServiceClient;
|
||||
use ZendService\Google\Gcm\Message as BaseServiceMessage;
|
||||
|
||||
@@ -74,11 +75,11 @@ class Gcm extends Units\Test
|
||||
->array($definedParameters = $object->getDefinedParameters())
|
||||
->isNotEmpty()
|
||||
->containsValues([
|
||||
'collapse_key',
|
||||
'delay_while_idle',
|
||||
'time_to_live',
|
||||
'restricted_package_name',
|
||||
'dry_run'
|
||||
'collapseKey',
|
||||
'delayWhileIdle',
|
||||
'ttl',
|
||||
'restrictedPackageName',
|
||||
'dryRun'
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -128,17 +129,48 @@ class Gcm extends Units\Test
|
||||
public function testGetServiceMessageFromOrigin()
|
||||
{
|
||||
$this->if($this->mockGenerator()->orphanize('__construct'))
|
||||
->and($this->mockClass('\Sly\NotificationPusher\Adapter\Gcm', '\Mock'))
|
||||
->and($this->mockClass(\Sly\NotificationPusher\Adapter\Gcm::class, '\Mock'))
|
||||
->and($object = new \Mock\Gcm())
|
||||
|
||||
->and($this->mockGenerator()->orphanize('__construct'))
|
||||
->and($this->mockClass('\Sly\NotificationPusher\Model\Message', '\Mock'))
|
||||
->and($this->mockClass(\Sly\NotificationPusher\Model\Message::class, '\Mock'))
|
||||
->and($message = new \Mock\Message())
|
||||
->and($message->getMockController()->getOptions = [
|
||||
'param' => 'test',
|
||||
'notificationData' => ['some' => 'foobar']
|
||||
])
|
||||
->and($message->getMockController()->getText = 'Test')
|
||||
|
||||
->object($object->getServiceMessageFromOrigin([self::GCM_TOKEN_EXAMPLE], $message))
|
||||
->isInstanceOf('\ZendService\Google\Gcm\Message')
|
||||
;
|
||||
->object($originalMessage = $object->getServiceMessageFromOrigin([self::GCM_TOKEN_EXAMPLE], $message))
|
||||
->isInstanceOf(\ZendService\Google\Gcm\Message::class)
|
||||
->array($originalMessage->getData())
|
||||
->notHasKey('notificationData')
|
||||
->array($originalMessage->getNotification())
|
||||
->hasKey('some')
|
||||
->contains('foobar');
|
||||
}
|
||||
|
||||
public function testGcmMessageUse()
|
||||
{
|
||||
$this->if($this->mockGenerator()->orphanize('__construct'))
|
||||
->and($this->mockClass(\Sly\NotificationPusher\Adapter\Gcm::class, '\Mock'))
|
||||
->and($object = new \Mock\Gcm())
|
||||
|
||||
->and($this->mockGenerator()->orphanize('__construct'))
|
||||
->and($this->mockClass(\Sly\NotificationPusher\Model\GcmMessage::class, '\Mock'))
|
||||
->and($message = new \Mock\GcmMessage())
|
||||
->and($message->getMockController()->getNotificationData = [
|
||||
'some' => 'foobar'
|
||||
])
|
||||
->and($message->getMockController()->getText = 'Test')
|
||||
|
||||
->object($originalMessage = $object->getServiceMessageFromOrigin([self::GCM_TOKEN_EXAMPLE], $message))
|
||||
->isInstanceOf(\ZendService\Google\Gcm\Message::class)
|
||||
->array($originalMessage->getData())
|
||||
->notHasKey('notificationData')
|
||||
->array($originalMessage->getNotification())
|
||||
->hasKey('some')
|
||||
->contains('foobar');
|
||||
}
|
||||
|
||||
public function testPush()
|
||||
@@ -146,6 +178,7 @@ class Gcm extends Units\Test
|
||||
$this->if($this->mockGenerator()->orphanize('__construct'))
|
||||
->and($this->mockClass('\Sly\NotificationPusher\Adapter\Gcm', '\Mock'))
|
||||
->and($object = new \Mock\Gcm())
|
||||
->and($object->setResponse(new Response()))
|
||||
|
||||
->and($this->mockClass('\ZendService\Google\Gcm\Response', '\Mock\ZendService'))
|
||||
->and($serviceResponse = new \Mock\ZendService\Response())
|
||||
|
||||
Reference in New Issue
Block a user