UnitOfWorkTestCase.php 7.27 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
/*
 *  $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
19
 * <http://www.phpdoctrine.org>.
zYne's avatar
zYne committed
20 21 22 23 24 25 26 27 28
 */

/**
 * 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
29
 * @link        www.phpdoctrine.org
zYne's avatar
zYne committed
30 31 32
 * @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'));
55
        $this->assertEqual($tree, $this->correct2);
zYne's avatar
zYne committed
56 57
    }
    public function testbuildFlushTree2() {
zYne's avatar
zYne committed
58
        $this->correct = array('Forum_Category','Forum_Board','Forum_Thread');
zYne's avatar
zYne committed
59

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

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