AbstractTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Mobile_Push_Message
  17. * @subpackage Push
  18. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id $
  21. */
  22. require_once 'Zend/Mobile/Push/Message/Abstract.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Mobile_Push_Message
  26. * @subpackage UnitTests
  27. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. * @group Zend_Mobile
  30. */
  31. class Zend_Mobile_Push_Message_AbstractTest extends PHPUnit_Framework_TestCase
  32. {
  33. public function setUp()
  34. {
  35. $this->msg = new Zend_Mobile_Push_Message_AbstractProxy();
  36. }
  37. public function testSetToken()
  38. {
  39. $token = 'a-token!';
  40. $ret = $this->msg->setToken($token);
  41. $this->assertEquals($this->msg, $ret);
  42. $this->assertEquals($token, $this->msg->getToken());
  43. }
  44. /**
  45. * @expectedException Zend_Mobile_Push_Message_Exception
  46. */
  47. public function testSetTokenThrowsExceptionOnNonStringToken()
  48. {
  49. $this->msg->setToken(array('dummy'));
  50. }
  51. public function testSetId()
  52. {
  53. $id = 'wahooo';
  54. $ret = $this->msg->setId($id);
  55. $this->assertEquals($this->msg, $ret);
  56. $this->assertEquals($id, $this->msg->getId());
  57. }
  58. /**
  59. * @expectedException Zend_Mobile_Push_Message_Exception
  60. */
  61. public function testSetIdThrowsExceptionOnNonScalar()
  62. {
  63. $this->msg->setId(array('foo'));
  64. }
  65. public function testSetOptions()
  66. {
  67. $token = 'token';
  68. $id = 'id';
  69. $ret = $this->msg->setOptions(array(
  70. 'id' => $id,
  71. 'token' => $token
  72. ));
  73. $this->assertEquals($this->msg, $ret);
  74. $this->assertEquals($token, $this->msg->getToken());
  75. $this->assertEquals($id, $this->msg->getId());
  76. }
  77. /**
  78. * @expectedException Zend_Mobile_Push_Message_Exception
  79. */
  80. public function testSetOptionsThrowsExceptionOnMissingMethod()
  81. {
  82. $this->msg->setOptions(array(
  83. 'thisMethodDoesNotExist' => 'value'
  84. ));
  85. }
  86. public function testValidateReturnsTrue()
  87. {
  88. $this->assertTrue($this->msg->validate());
  89. }
  90. }
  91. class Zend_Mobile_Push_Message_AbstractProxy extends Zend_Mobile_Push_Message_Abstract
  92. {
  93. }