8
* This source file is subject to the new BSD license that is bundled
9
* with this package in the file LICENSE.txt.
10
* It is also available through the world-wide-web at this URL:
11
* http://framework.zend.com/license/new-bsd
12
* If you did not receive a copy of the license and are unable to
13
* obtain it through the world-wide-web, please send an email
14
* to license@zend.com so we can send you a copy immediately.
17
* @package Zend_Gdata_Gapps
18
* @subpackage UnitTests
19
* @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com);
20
* @license http://framework.zend.com/license/new-bsd New BSD License
23
require_once 'Zend/Gdata/Gapps/Error.php';
24
require_once 'Zend/Gdata/Gapps.php';
28
* @subpackage UnitTests
30
class Zend_Gdata_Gapps_ErrorTest extends PHPUnit_Framework_TestCase
33
public function setUp() {
34
$this->error = new Zend_Gdata_Gapps_Error();
37
public function testCanSetAndGetErrorCodeUsingConstant() {
38
$this->error->setErrorCode(
39
Zend_Gdata_Gapps_Error::INVALID_EMAIL_ADDRESS);
40
$this->assertEquals(Zend_Gdata_Gapps_Error::INVALID_EMAIL_ADDRESS,
41
$this->error->getErrorCode());
44
public function testCanSetAndGetErrorCodeUsingInteger() {
45
$this->error->setErrorCode(123);
46
$this->assertEquals(123, $this->error->getErrorCode());
49
public function testCanSetAndGetReason() {
50
$text = "The foo is missing a bar.";
51
$this->error->setReason($text);
52
$this->assertEquals($text, $this->error->getReason());
55
public function testCanSetAndGetInvalidInput() {
57
$this->error->setInvalidInput($text);
58
$this->assertEquals($text, $this->error->getInvalidInput());
61
public function testContstructorAllowsSettingAllVariables() {
62
$this->error = new Zend_Gdata_Gapps_Error(
63
Zend_Gdata_Gapps_Error::USER_DELETED_RECENTLY,
65
$this->assertEquals(Zend_Gdata_Gapps_Error::USER_DELETED_RECENTLY,
66
$this->error->getErrorCode());
67
$this->assertEquals("foo", $this->error->getReason());
68
$this->assertEquals("bar", $this->error->getInvalidInput());
71
public function testToStringProvidesHelpfulMessage() {
72
$this->error->setErrorCode(Zend_Gdata_Gapps_Error::USER_SUSPENDED);
73
$this->error->setReason("The foo is missing a bar.");
74
$this->error->setInvalidInput("for___baz");
75
$this->assertEquals("Error 1101: The foo is missing a bar.\n\tInvalid Input: \"for___baz\"", $this->error->__toString());
77
$this->error->setErrorCode(Zend_Gdata_Gapps_Error::UNKNOWN_ERROR);
78
$this->error->setReason("Unknown error.");
79
$this->error->setInvalidInput("blah");
80
$this->assertEquals("Error 1000: Unknown error.\n\tInvalid Input: \"blah\"", $this->error->__toString());