update v1.0.7.9 R.C.
This is a Release Candidate. We are still testing.
This commit is contained in:
50
vendor/sly/notification-pusher/tests/units/Sly/NotificationPusher/Model/BaseOptionedModel.php
vendored
Normal file
50
vendor/sly/notification-pusher/tests/units/Sly/NotificationPusher/Model/BaseOptionedModel.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace tests\units\Sly\NotificationPusher\Model;
|
||||
|
||||
use mageekguy\atoum as Units;
|
||||
use Sly\NotificationPusher\Model\Message;
|
||||
|
||||
/**
|
||||
* BaseOptionedModel.
|
||||
*
|
||||
* @uses atoum\test
|
||||
* @author Cédric Dugat <cedric@dugat.me>
|
||||
*/
|
||||
class BaseOptionedModel extends Units\Test
|
||||
{
|
||||
public function testMethods()
|
||||
{
|
||||
$this->if($object = new Message('Test', array('param' => 'test')))
|
||||
->boolean($object->hasOption('param'))
|
||||
->isTrue()
|
||||
->string($object->getOption('param'))
|
||||
->isEqualTo('test')
|
||||
|
||||
->boolean($object->hasOption('notExist'))
|
||||
->isFalse()
|
||||
->variable($object->getOption('notExist'))
|
||||
->isNull()
|
||||
->string($object->getOption('renotExist', '12345'))
|
||||
->isEqualTo('12345')
|
||||
|
||||
->when($object->setOptions(array('chuck' => 'norris')))
|
||||
->boolean($object->hasOption('chuck'))
|
||||
->isTrue()
|
||||
->string($object->getOption('chuck'))
|
||||
->isEqualTo('norris')
|
||||
|
||||
->when($object->setOption('poney', 'powerful'))
|
||||
->boolean($object->hasOption('poney'))
|
||||
->isTrue()
|
||||
->string($object->getOption('poney'))
|
||||
->isEqualTo('powerful')
|
||||
|
||||
->when($object->setOption('null', null))
|
||||
->boolean($object->hasOption('null'))
|
||||
->isTrue()
|
||||
->variable($object->getOption('null'))
|
||||
->isNull()
|
||||
;
|
||||
}
|
||||
}
|
50
vendor/sly/notification-pusher/tests/units/Sly/NotificationPusher/Model/BaseParameteredModel.php
vendored
Normal file
50
vendor/sly/notification-pusher/tests/units/Sly/NotificationPusher/Model/BaseParameteredModel.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace tests\units\Sly\NotificationPusher\Model;
|
||||
|
||||
use mageekguy\atoum as Units;
|
||||
use Sly\NotificationPusher\Model\Device;
|
||||
|
||||
/**
|
||||
* BaseParameteredModel.
|
||||
*
|
||||
* @uses atoum\test
|
||||
* @author Cédric Dugat <cedric@dugat.me>
|
||||
*/
|
||||
class BaseParameteredModel extends Units\Test
|
||||
{
|
||||
public function testMethods()
|
||||
{
|
||||
$this->if($object = new Device('Test', array('param' => 'test')))
|
||||
->boolean($object->hasParameter('param'))
|
||||
->isTrue()
|
||||
->string($object->getParameter('param'))
|
||||
->isEqualTo('test')
|
||||
|
||||
->boolean($object->hasParameter('notExist'))
|
||||
->isFalse()
|
||||
->variable($object->getParameter('notExist'))
|
||||
->isNull()
|
||||
->string($object->getParameter('renotExist', '12345'))
|
||||
->isEqualTo('12345')
|
||||
|
||||
->when($object->setParameters(array('chuck' => 'norris')))
|
||||
->boolean($object->hasParameter('chuck'))
|
||||
->isTrue()
|
||||
->string($object->getParameter('chuck'))
|
||||
->isEqualTo('norris')
|
||||
|
||||
->when($object->setParameter('poney', 'powerful'))
|
||||
->boolean($object->hasParameter('poney'))
|
||||
->isTrue()
|
||||
->string($object->getParameter('poney'))
|
||||
->isEqualTo('powerful')
|
||||
|
||||
->when($object->setParameter('null', null))
|
||||
->boolean($object->hasParameter('null'))
|
||||
->isTrue()
|
||||
->variable($object->getParameter('null'))
|
||||
->isNull()
|
||||
;
|
||||
}
|
||||
}
|
34
vendor/sly/notification-pusher/tests/units/Sly/NotificationPusher/Model/Device.php
vendored
Normal file
34
vendor/sly/notification-pusher/tests/units/Sly/NotificationPusher/Model/Device.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace tests\units\Sly\NotificationPusher\Model;
|
||||
|
||||
use mageekguy\atoum as Units;
|
||||
use Sly\NotificationPusher\Model\Device as TestedModel;
|
||||
|
||||
/**
|
||||
* Device.
|
||||
*
|
||||
* @uses atoum\test
|
||||
* @author Cédric Dugat <cedric@dugat.me>
|
||||
*/
|
||||
class Device extends Units\Test
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$this->if($object = new TestedModel('t0k3n'))
|
||||
->string($object->getToken())->isEqualTo('t0k3n')
|
||||
->array($object->getParameters())->isEmpty()
|
||||
;
|
||||
|
||||
$this->if($object = new TestedModel('t0k3n', array('param' => 'test')))
|
||||
->string($object->getToken())->isEqualTo('t0k3n')
|
||||
->when($object->setToken('t0k3ns3tt3d'))
|
||||
->string($object->getToken())->isEqualTo('t0k3ns3tt3d')
|
||||
->array($object->getParameters())
|
||||
->hasKey('param')
|
||||
->contains('test')
|
||||
->size
|
||||
->isEqualTo(1)
|
||||
;
|
||||
}
|
||||
}
|
34
vendor/sly/notification-pusher/tests/units/Sly/NotificationPusher/Model/Message.php
vendored
Normal file
34
vendor/sly/notification-pusher/tests/units/Sly/NotificationPusher/Model/Message.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace tests\units\Sly\NotificationPusher\Model;
|
||||
|
||||
use mageekguy\atoum as Units;
|
||||
use Sly\NotificationPusher\Model\Message as TestedModel;
|
||||
|
||||
/**
|
||||
* Message.
|
||||
*
|
||||
* @uses atoum\test
|
||||
* @author Cédric Dugat <cedric@dugat.me>
|
||||
*/
|
||||
class Message extends Units\Test
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$this->if($object = new TestedModel('Test'))
|
||||
->string($object->getText())->isEqualTo('Test')
|
||||
->array($object->getOptions())->isEmpty()
|
||||
;
|
||||
|
||||
$this->if($object = new TestedModel('Test', array('param' => 'test')))
|
||||
->string($object->getText())->isEqualTo('Test')
|
||||
->when($object->setText('Test 2'))
|
||||
->string($object->getText())->isEqualTo('Test 2')
|
||||
->array($object->getOptions())
|
||||
->hasKey('param')
|
||||
->contains('test')
|
||||
->size
|
||||
->isEqualTo(1)
|
||||
;
|
||||
}
|
||||
}
|
165
vendor/sly/notification-pusher/tests/units/Sly/NotificationPusher/Model/Push.php
vendored
Normal file
165
vendor/sly/notification-pusher/tests/units/Sly/NotificationPusher/Model/Push.php
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
namespace tests\units\Sly\NotificationPusher\Model;
|
||||
|
||||
use mageekguy\atoum as Units;
|
||||
use Sly\NotificationPusher\Model\Push as TestedModel;
|
||||
|
||||
use Sly\NotificationPusher\Model\Message as BaseMessage;
|
||||
use Sly\NotificationPusher\Model\Device as BaseDevice;
|
||||
use Sly\NotificationPusher\Collection\DeviceCollection as BaseDeviceCollection;
|
||||
use Sly\NotificationPusher\Adapter\Apns as BaseApnsAdapter;
|
||||
|
||||
/**
|
||||
* Push.
|
||||
*
|
||||
* @uses atoum\test
|
||||
* @author Cédric Dugat <cedric@dugat.me>
|
||||
*/
|
||||
class Push extends Units\Test
|
||||
{
|
||||
const APNS_TOKEN_EXAMPLE = '111db24975bb6c6b63214a8d268052aa0a965cc1e32110ab06a72b19074c2222';
|
||||
const GCM_TOKEN_EXAMPLE = 'AAA91bG9ISdL94D55C69NplFlxicy0iFUFTyWh3AAdMfP9npH5r_JQFTo27xpX1jfqGf-aSe6xZAsfWRefjazJpqFt03Isanv-Fi97020EKLye0ApTkHsw_0tJJzgA2Js0NsG1jLWsiJf63YSF8ropAcRp4BSxVBBB';
|
||||
|
||||
public function testConstructWithOneDevice()
|
||||
{
|
||||
$this->if($this->mockClass('\Sly\NotificationPusher\Adapter\AdapterInterface', '\Mock'))
|
||||
->and($adapter = new \Mock\AdapterInterface())
|
||||
->and($devices = new BaseDevice('Token1'))
|
||||
->and($message = new BaseMessage('Test'))
|
||||
|
||||
->and($object = new TestedModel($adapter, $devices, $message))
|
||||
|
||||
->object($object->getDevices())
|
||||
->isInstanceOf('\Sly\NotificationPusher\Collection\DeviceCollection')
|
||||
->integer($object->getDevices()->count())
|
||||
->isEqualTo(1)
|
||||
->array($object->getOptions())
|
||||
->isEmpty()
|
||||
;
|
||||
}
|
||||
|
||||
public function testConstructWithManyDevicesAndOptions()
|
||||
{
|
||||
$this->if($this->mockClass('\Sly\NotificationPusher\Adapter\AdapterInterface', '\Mock'))
|
||||
->and($adapter = new \Mock\AdapterInterface())
|
||||
->and($devices = new BaseDeviceCollection(array(new BaseDevice('Token1'), new BaseDevice('Token2'), new BaseDevice('Token3'))))
|
||||
->and($message = new BaseMessage('Test'))
|
||||
|
||||
->and($object = new TestedModel($adapter, $devices, $message, array('param' => 'test')))
|
||||
|
||||
->object($object->getDevices())
|
||||
->isInstanceOf('\Sly\NotificationPusher\Collection\DeviceCollection')
|
||||
->integer($object->getDevices()->count())
|
||||
->isEqualTo(3)
|
||||
->array($object->getOptions())
|
||||
->hasKey('param')
|
||||
->contains('test')
|
||||
->size
|
||||
->isEqualTo(1)
|
||||
;
|
||||
}
|
||||
|
||||
public function testStatus()
|
||||
{
|
||||
$this->if($this->mockClass('\Sly\NotificationPusher\Adapter\AdapterInterface', '\Mock'))
|
||||
->and($adapter = new \Mock\AdapterInterface())
|
||||
->and($devices = new BaseDeviceCollection(array(new BaseDevice('Token1'), new BaseDevice('Token2'), new BaseDevice('Token3'))))
|
||||
->and($message = new BaseMessage('Test'))
|
||||
|
||||
->and($object = new TestedModel($adapter, $devices, $message))
|
||||
|
||||
->string($object->getStatus())
|
||||
->isEqualTo(TestedModel::STATUS_PENDING)
|
||||
->boolean($object->isPushed())
|
||||
->isFalse()
|
||||
|
||||
->when($object->pushed())
|
||||
->and($dt = new \DateTime())
|
||||
->string($object->getStatus())
|
||||
->isEqualTo(TestedModel::STATUS_PUSHED)
|
||||
->boolean($object->isPushed())
|
||||
->isTrue()
|
||||
->dateTime($object->getPushedAt())
|
||||
->isCloneOf($dt)
|
||||
|
||||
->when($object->setStatus(TestedModel::STATUS_PENDING))
|
||||
->string($object->getStatus())
|
||||
->isEqualTo(TestedModel::STATUS_PENDING)
|
||||
->boolean($object->isPushed())
|
||||
->isFalse()
|
||||
|
||||
->when($fDt = new \DateTime('2013-01-01'))
|
||||
->and($object->setPushedAt($fDt))
|
||||
->dateTime($object->getPushedAt())
|
||||
->isCloneOf(new \DateTime('2013-01-01'))
|
||||
;
|
||||
}
|
||||
|
||||
public function testDevicesTokensCheck()
|
||||
{
|
||||
$this->if($this->mockGenerator()->orphanize('__construct'))
|
||||
->and($this->mockClass('\Sly\NotificationPusher\Adapter\Apns', '\Mock'))
|
||||
->and($this->mockGenerator()->orphanize('__construct'))
|
||||
->and($this->mockClass('\Sly\NotificationPusher\Adapter\Gcm', '\Mock'))
|
||||
|
||||
->and($apnsAdapter = new \mock\Apns())
|
||||
->and($gcmAdapter = new \mock\Gcm())
|
||||
->and($badDevice = new BaseDevice('BadToken'))
|
||||
->and($message = new BaseMessage('Test'))
|
||||
|
||||
->exception(function () use ($apnsAdapter, $badDevice, $message) {
|
||||
$object = new TestedModel($apnsAdapter, $badDevice, $message);
|
||||
})
|
||||
->isInstanceOf('\Sly\NotificationPusher\Exception\AdapterException')
|
||||
|
||||
->when($goodDevice = new BaseDevice(self::APNS_TOKEN_EXAMPLE))
|
||||
->object($object = new TestedModel($apnsAdapter, $goodDevice, $message))
|
||||
;
|
||||
}
|
||||
|
||||
public function testAdapter()
|
||||
{
|
||||
$this->if($this->mockGenerator()->orphanize('__construct'))
|
||||
->and($this->mockClass('\Sly\NotificationPusher\Adapter\Apns', '\Mock'))
|
||||
->and($this->mockGenerator()->orphanize('__construct'))
|
||||
->and($this->mockClass('\Sly\NotificationPusher\Adapter\Gcm', '\Mock'))
|
||||
|
||||
->and($apnsAdapter = new \mock\Apns())
|
||||
->and($gcmAdapter = new \mock\Gcm())
|
||||
->and($devices = new BaseDevice(self::APNS_TOKEN_EXAMPLE))
|
||||
->and($message = new BaseMessage('Test'))
|
||||
|
||||
->and($object = new TestedModel($apnsAdapter, $devices, $message))
|
||||
|
||||
->object($object->getAdapter())
|
||||
->isInstanceOf('\Sly\NotificationPusher\Adapter\Apns')
|
||||
|
||||
->when($object->setAdapter($gcmAdapter))
|
||||
->and($object->setDevices(new BaseDeviceCollection(array(new BaseDevice(self::GCM_TOKEN_EXAMPLE)))))
|
||||
->object($object->getAdapter())
|
||||
->isInstanceOf('\Sly\NotificationPusher\Adapter\Gcm')
|
||||
;
|
||||
}
|
||||
|
||||
public function testMessage()
|
||||
{
|
||||
$this->if($this->mockClass('\Sly\NotificationPusher\Adapter\AdapterInterface', '\Mock'))
|
||||
->and($adapter = new \Mock\AdapterInterface())
|
||||
->and($devices = new BaseDeviceCollection(array(new BaseDevice('Token1'), new BaseDevice('Token2'), new BaseDevice('Token3'))))
|
||||
->and($message = new BaseMessage('Test'))
|
||||
|
||||
->and($object = new TestedModel($adapter, $devices, $message))
|
||||
->object($object->getMessage())
|
||||
->isInstanceOf('\Sly\NotificationPusher\Model\Message')
|
||||
->string($object->getMessage()->getText())
|
||||
->isEqualTo('Test')
|
||||
|
||||
->when($object->setMessage(new BaseMessage('Test 2')))
|
||||
->object($object->getMessage())
|
||||
->isInstanceOf('\Sly\NotificationPusher\Model\Message')
|
||||
->string($object->getMessage()->getText())
|
||||
->isEqualTo('Test 2')
|
||||
;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user