UnitOfWorkTestCase.php 7.33 KB
Newer Older
zYne's avatar
zYne committed
1
<?php
zYne's avatar
zYne committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
/*
 *  $Id$
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the LGPL. For more information, see
 * <http://www.phpdoctrine.com>.
 */

/**
 * Doctrine_UnitOfWork_TestCase
 *
 * @package     Doctrine
 * @author      Konsta Vesterinen <kvesteri@cc.hut.fi>
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
 * @category    Object Relational Mapping
 * @link        www.phpdoctrine.com
 * @since       1.0
 * @version     $Revision$
 */
zYne's avatar
zYne committed
33
class Doctrine_UnitOfWork_TestCase extends Doctrine_UnitTestCase {
zYne's avatar
zYne committed
34
    private $correct  = array('Task', 'ResourceType', 'Resource', 'Assignment', 'ResourceReference');
zYne's avatar
zYne committed
35 36 37 38 39 40 41 42 43 44
    private $correct2 = array (
              0 => 'Resource',
              1 => 'Task',
              2 => 'ResourceType',
              3 => 'Assignment',
              4 => 'ResourceReference',
            );
    public function testbuildFlushTree() {
        $task = new Task();

zYne's avatar
zYne committed
45 46
        $tree = $this->unitOfWork->buildFlushTree(array('Task'));
        $this->assertEqual($tree,array('Resource', 'Task', 'Assignment'));
zYne's avatar
zYne committed
47

zYne's avatar
zYne committed
48
        $tree = $this->unitOfWork->buildFlushTree(array('Task','Resource'));
zYne's avatar
zYne committed
49 50
        $this->assertEqual($tree, $this->correct);

zYne's avatar
zYne committed
51
        $tree = $this->unitOfWork->buildFlushTree(array('Task', 'Assignment', 'Resource'));
zYne's avatar
zYne committed
52 53
        $this->assertEqual($tree, $this->correct);

zYne's avatar
zYne committed
54
        $tree = $this->unitOfWork->buildFlushTree(array('Assignment', 'Task', 'Resource'));
zYne's avatar
zYne committed
55

zYne's avatar
zYne committed
56
        $this->assertEqual($tree, array('Resource', 'Task', 'ResourceType', 'Assignment', 'ResourceReference'));
zYne's avatar
zYne committed
57 58
    }
    public function testbuildFlushTree2() {
zYne's avatar
zYne committed
59
        $this->correct = array('Forum_Category','Forum_Board','Forum_Thread');
zYne's avatar
zYne committed
60

zYne's avatar
zYne committed
61
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Board'));
zYne's avatar
zYne committed
62
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
63
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Category','Forum_Board'));
zYne's avatar
zYne committed
64 65 66
        $this->assertEqual($tree, $this->correct);
    }
    public function testBuildFlushTree3() {
zYne's avatar
zYne committed
67
        $this->correct = array('Forum_Category','Forum_Board','Forum_Thread','Forum_Entry');
zYne's avatar
zYne committed
68

zYne's avatar
zYne committed
69
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Entry','Forum_Board'));
zYne's avatar
zYne committed
70
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
71
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Board','Forum_Entry'));
zYne's avatar
zYne committed
72 73 74
        $this->assertEqual($tree, $this->correct);
    }
    public function testBuildFlushTree4() {
zYne's avatar
zYne committed
75
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Thread','Forum_Board'));
zYne's avatar
zYne committed
76
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
77
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Board','Forum_Thread'));
zYne's avatar
zYne committed
78 79 80
        $this->assertEqual($tree, $this->correct);
    }
    public function testBuildFlushTree5() {
zYne's avatar
zYne committed
81
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Board','Forum_Thread','Forum_Entry'));
zYne's avatar
zYne committed
82
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
83
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Board','Forum_Entry','Forum_Thread'));
zYne's avatar
zYne committed
84 85 86
        $this->assertEqual($tree, $this->correct);
    }
    public function testBuildFlushTree6() {
zYne's avatar
zYne committed
87
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Entry','Forum_Board','Forum_Thread'));
zYne's avatar
zYne committed
88
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
89
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Entry','Forum_Thread','Forum_Board'));
zYne's avatar
zYne committed
90 91 92
        $this->assertEqual($tree, $this->correct);
    }
    public function testBuildFlushTree7() {
zYne's avatar
zYne committed
93
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Thread','Forum_Board','Forum_Entry'));
zYne's avatar
zYne committed
94
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
95
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Thread','Forum_Entry','Forum_Board'));
zYne's avatar
zYne committed
96 97 98
        $this->assertEqual($tree, $this->correct);
    }
    public function testBuildFlushTree8() {
zYne's avatar
zYne committed
99
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Board','Forum_Thread','Forum_Category'));
zYne's avatar
zYne committed
100
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
101
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Category','Forum_Thread','Forum_Board'));
zYne's avatar
zYne committed
102
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
103
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Thread','Forum_Board','Forum_Category'));
zYne's avatar
zYne committed
104 105 106
        $this->assertEqual($tree, $this->correct);
    }
    public function testBuildFlushTree9() {
zYne's avatar
zYne committed
107
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Board','Forum_Thread','Forum_Category','Forum_Entry'));
zYne's avatar
zYne committed
108
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
109
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Board','Forum_Thread','Forum_Entry','Forum_Category'));
zYne's avatar
zYne committed
110
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
111
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Board','Forum_Category','Forum_Thread','Forum_Entry'));
zYne's avatar
zYne committed
112 113 114
        $this->assertEqual($tree, $this->correct);
    }
    public function testBuildFlushTree10() {
zYne's avatar
zYne committed
115
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Entry','Forum_Thread','Forum_Board','Forum_Category'));
zYne's avatar
zYne committed
116
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
117
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Entry','Forum_Thread','Forum_Category','Forum_Board'));
zYne's avatar
zYne committed
118
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
119
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Entry','Forum_Category','Forum_Board','Forum_Thread'));
zYne's avatar
zYne committed
120 121 122
        $this->assertEqual($tree, $this->correct);
    }
    public function testBuildFlushTree11() {
zYne's avatar
zYne committed
123
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Thread','Forum_Category','Forum_Board','Forum_Entry'));
zYne's avatar
zYne committed
124
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
125
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Thread','Forum_Entry','Forum_Category','Forum_Board'));
zYne's avatar
zYne committed
126
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
127
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Thread','Forum_Board','Forum_Entry','Forum_Category'));
zYne's avatar
zYne committed
128 129 130
        $this->assertEqual($tree, $this->correct);
    }
    public function testBuildFlushTree12() {
zYne's avatar
zYne committed
131
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Category','Forum_Entry','Forum_Board','Forum_Thread'));
zYne's avatar
zYne committed
132
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
133
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Category','Forum_Thread','Forum_Entry','Forum_Board'));
zYne's avatar
zYne committed
134
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
135
        $tree = $this->unitOfWork->buildFlushTree(array('Forum_Category','Forum_Board','Forum_Thread','Forum_Entry'));
zYne's avatar
zYne committed
136
        $this->assertEqual($tree, $this->correct);
zYne's avatar
zYne committed
137
    }
zYne's avatar
zYne committed
138
}