/
TestComposeOne.php
50 lines (39 loc) · 1.22 KB
/
TestComposeOne.php
1
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* @author Jonathan Moss <xirisr@gmail.com>
* @copyright 2010 Jonathan Moss
* @package Morph
*/
require_once dirname(__FILE__).'/../Morph.phar';
require_once dirname(__FILE__).'/mongoUnit/TestCase.php';
require_once dirname(__FILE__).'/test-objects/ComposeOneParent.php';
require_once dirname(__FILE__).'/test-objects/Child.php';
/**
* @package Morph
*/
class TestComposeOne extends \mongoUnit\TestCase
{
public function setup()
{
parent::setup();
\morph\Storage::init($this->getDatabase());
}
public function tearDown()
{
parent::tearDown();
\morph\Storage::deInit();
}
public function testStoresParentAndChild()
{
$parent = new ComposeOneParent();
$parent->Name = 'Compose One Parent';
$child = new Child();
$child->Name = 'Child';
$parent->Child = $child;
$parent->save();
$this->assertCollectionExists('ComposeOneParent');
$this->assertCollectionDoesNotExist('Child');
$this->assertDocumentExists('ComposeOneParent', $parent->id());
$this->assertDocumentPropertyEquals(array('_ns'=>'Child', 'Name'=>'Child', 'Age' => null), 'ComposeOneParent', 'Child', $parent->id());
}
}