~clinton-collins/familyproject/trunk

« back to all changes in this revision

Viewing changes to ZendFramework/tests/Zend/Gdata/Gapps/ErrorTest.php

  • Committer: Clinton Collins
  • Date: 2009-06-26 19:54:58 UTC
  • Revision ID: clinton.collins@gmail.com-20090626195458-5ebba0qcvo15xlpy
Initial Import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Zend Framework
 
5
 *
 
6
 * LICENSE
 
7
 *
 
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.
 
15
 *
 
16
 * @category     Zend
 
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
 
21
 */
 
22
 
 
23
require_once 'Zend/Gdata/Gapps/Error.php';
 
24
require_once 'Zend/Gdata/Gapps.php';
 
25
 
 
26
/**
 
27
 * @package Zend_Gdata
 
28
 * @subpackage UnitTests
 
29
 */
 
30
class Zend_Gdata_Gapps_ErrorTest extends PHPUnit_Framework_TestCase
 
31
{
 
32
 
 
33
    public function setUp() {
 
34
        $this->error = new Zend_Gdata_Gapps_Error();
 
35
    }
 
36
 
 
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());
 
42
    }
 
43
 
 
44
    public function testCanSetAndGetErrorCodeUsingInteger() {
 
45
        $this->error->setErrorCode(123);
 
46
        $this->assertEquals(123, $this->error->getErrorCode());
 
47
    }
 
48
 
 
49
   public function testCanSetAndGetReason() {
 
50
        $text = "The foo is missing a bar.";
 
51
        $this->error->setReason($text);
 
52
        $this->assertEquals($text, $this->error->getReason());
 
53
    }
 
54
 
 
55
    public function testCanSetAndGetInvalidInput() {
 
56
         $text = "for___baz";
 
57
         $this->error->setInvalidInput($text);
 
58
         $this->assertEquals($text, $this->error->getInvalidInput());
 
59
    }
 
60
 
 
61
    public function testContstructorAllowsSettingAllVariables() {
 
62
        $this->error = new Zend_Gdata_Gapps_Error(
 
63
            Zend_Gdata_Gapps_Error::USER_DELETED_RECENTLY,
 
64
            "foo", "bar");
 
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());
 
69
    }
 
70
 
 
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());
 
76
 
 
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());
 
81
    }
 
82
 
 
83
}