~clinton-collins/familyproject/trunk

« back to all changes in this revision

Viewing changes to ZendFramework/tests/Zend/Gdata/App/GeneratorTest.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
 * @generator     Zend
 
17
 * @package      Zend_Gdata_App
 
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/App/Extension/Generator.php';
 
24
require_once 'Zend/Gdata/App/Extension/Draft.php';
 
25
require_once 'Zend/Gdata/App.php';
 
26
 
 
27
/**
 
28
 * @package Zend_Gdata_App
 
29
 * @subpackage UnitTests
 
30
 */
 
31
class Zend_Gdata_App_GeneratorTest extends PHPUnit_Framework_TestCase
 
32
{
 
33
 
 
34
    public function setUp() {
 
35
        $this->generatorText = file_get_contents(
 
36
                'Zend/Gdata/App/_files/GeneratorElementSample1.xml',
 
37
                true);
 
38
        $this->generator = new Zend_Gdata_App_Extension_Generator();
 
39
    }
 
40
      
 
41
    public function testEmptyGeneratorShouldHaveEmptyExtensionsList() {
 
42
        $this->assertTrue(is_array($this->generator->extensionElements));
 
43
        $this->assertTrue(count($this->generator->extensionElements) == 0);
 
44
    }
 
45
      
 
46
    public function testEmptyGeneratorToAndFromStringShouldMatch() {
 
47
        $generatorXml = $this->generator->saveXML();
 
48
        $newGenerator = new Zend_Gdata_App_Extension_Generator();
 
49
        $newGenerator->transferFromXML($generatorXml);
 
50
        $newGeneratorXml = $newGenerator->saveXML();
 
51
        $this->assertTrue($generatorXml == $newGeneratorXml);
 
52
    }
 
53
 
 
54
    public function testGeneratorToAndFromStringShouldMatch() {
 
55
        $this->generator->uri = 'http://code.google.com/apis/gdata/';
 
56
        $this->generator->version = '1.0';
 
57
        $this->generator->text = 'Google data APIs';
 
58
        $generatorXml = $this->generator->saveXML();
 
59
        $newGenerator = new Zend_Gdata_App_Extension_Generator();
 
60
        $newGenerator->transferFromXML($generatorXml);
 
61
        $newGeneratorXml = $newGenerator->saveXML();
 
62
        $this->assertEquals($newGeneratorXml, $generatorXml);
 
63
        $this->assertEquals('http://code.google.com/apis/gdata/', 
 
64
                $newGenerator->uri);
 
65
        $this->assertEquals('1.0', $newGenerator->version);
 
66
        $this->assertEquals('Google data APIs', $newGenerator->text);
 
67
    }
 
68
 
 
69
    public function testConvertGeneratorWithDraftToAndFromString() {
 
70
        $this->generator->transferFromXML($this->generatorText);
 
71
        $this->assertEquals('http://code.google.com/apis/gdata/', 
 
72
                $this->generator->uri);
 
73
        $this->assertEquals('1.0', $this->generator->version);
 
74
        $this->assertEquals('Google data APIs', $this->generator->text);
 
75
    }
 
76
 
 
77
}