My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes  
Changes to /trunk/mongodb-morph/integration-tests/TestComposeMany.php
r120 vs. r144 Compare: vs.  Format:
Revision r144
Go to: 
Project members, sign in to write a code review
/trunk/mongodb-morph/integration-tests/TestComposeMany.php   r120 /trunk/mongodb-morph/integration-tests/TestComposeMany.php   r144
1 <?php 1 <?php
2 /** 2 /**
3 * @author Jonathan Moss <xirisr@gmail.com> 3 * @author Jonathan Moss <xirisr@gmail.com>
4 * @copyright 2010 Jonathan Moss 4 * @copyright 2010 Jonathan Moss
5 * @package Morph 5 * @package Morph
6 */ 6 */
7 7
8 require_once dirname(__FILE__).'/../Morph.phar'; 8 require_once dirname(__FILE__).'/../Morph.phar';
9 require_once dirname(__FILE__).'/MongoUnit/TestCase.php'; 9 require_once dirname(__FILE__).'/MongoUnit/TestCase.php';
10 require_once dirname(__FILE__).'/test-objects/ComposeManyParent.php'; 10 require_once dirname(__FILE__).'/test-objects/ComposeManyParent.php';
11 require_once dirname(__FILE__).'/test-objects/Child.php'; 11 require_once dirname(__FILE__).'/test-objects/Child.php';
12 12
13 /** 13 /**
14 * @package Morph 14 * @package Morph
15 */ 15 */
16 class TestComposeMany extends MongoUnit_TestCase 16 class TestComposeMany extends MongoUnit_TestCase
17 { 17 {
18 18
19 public function setup() 19 public function setup()
20 { 20 {
21 parent::setUp(); 21 parent::setUp();
22 Morph_Storage::init($this->getDatabase()); 22 Morph_Storage::init($this->getDatabase());
23 } 23 }
24 24
25 public function tearDown() 25 public function tearDown()
26 { 26 {
27 parent::tearDown(); 27 parent::tearDown();
28 Morph_Storage::deInit(); 28 Morph_Storage::deInit();
29 } 29 }
30 30
31 public function testStoresParentAndChild() 31 public function testStoresParentAndChild()
32 { 32 {
33 $parent = new ComposeManyParent(); 33 $parent = new ComposeManyParent();
34 $parent->Name = 'Compose Many Parent'; 34 $parent->Name = 'Compose Many Parent';
35 35
36 $child1 = new Child(); 36 $child1 = new Child();
37 $child1->Name = 'Child1'; 37 $child1->Name = 'Child1';
38 38
39 $child2 = new Child(); 39 $child2 = new Child();
40 $child2->Name = 'Child2'; 40 $child2->Name = 'Child2';
41 41
42 $parent->Children[] = $child1; 42 $parent->Children[] = $child1;
43 $parent->Children[] = $child2; 43 $parent->Children[] = $child2;
44 44
45 $parent->save(); 45 $parent->save();
46 $this->assertCollectionExists('ComposeManyParent'); 46 $this->assertCollectionExists('ComposeManyParent');
47 $this->assertCollectionDoesNotExist('Child'); 47 $this->assertCollectionDoesNotExist('Child');
48 48
49 $this->assertDocumentExists('ComposeManyParent', $parent->id()); 49 $this->assertDocumentExists('ComposeManyParent', $parent->id());
50 50
51 $expected = array ( 51 $expected = array (
52 array('_ns'=>'Child', 'Name'=>'Child1'), 52 array('_ns'=>'Child', 'Name'=>'Child1', 'Age' => null),
53 array('_ns'=>'Child', 'Name'=>'Child2') 53 array('_ns'=>'Child', 'Name'=>'Child2', 'Age' => null)
54 ); 54 );
55 55
56 $this->assertDocumentPropertyEquals($expected, 'ComposeManyParent', 'Children', $parent->id()); 56 $this->assertDocumentPropertyEquals($expected, 'ComposeManyParent', 'Children', $parent->id());
57 } 57 }
58 58
59 } 59 }
Powered by Google Project Hosting