This repository has been archived by the owner on Feb 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
/
DocumentInheritTest.php
56 lines (46 loc) · 1.75 KB
/
DocumentInheritTest.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
51
52
53
54
55
56
<?php
namespace Doctrine\Tests\ODM\CouchDB\Functional\Mapping;
use Doctrine\ODM\CouchDB\DocumentManager;
use Doctrine\Tests\Models\Mapping\HeadlineArticle;
use Doctrine\Tests\ODM\CouchDB\CouchDBFunctionalTestCase;
use Doctrine\Tests\Models\Mapping\ExtendingClass;
/**
* Test about mapped superclass and about extending a base document
*/
class DocumentInheritTest extends CouchDBFunctionalTestCase
{
/** @var DocumentManager */
private $dm;
public function setUp()
{
$this->dm = $this->createDocumentManager();
}
public function testLoadingParentClass()
{
$document = new HeadlineArticle();
$document->topic = 'Superclass test';
$document->headline = 'test test test';
$this->dm->persist($document);
$this->dm->flush();
$id = $document->id;
$this->dm->clear();
$doc = $this->dm->find('Doctrine\Tests\Models\Mapping\HeadlineArticle', $id);
$this->assertInstanceOf('\Doctrine\Tests\Models\Mapping\HeadlineArticle', $doc);
$this->assertEquals('test test test', $doc->headline);
$this->assertEquals('Superclass test', $doc->topic);
}
public function testLoadingMappedsuperclass()
{
$document = new ExtendingClass();
$document->topic = 'Superclass test';
$document->headline = 'test test test';
$this->dm->persist($document);
$this->dm->flush();
$id = $document->id;
$this->dm->clear();
$doc = $this->dm->find('Doctrine\Tests\Models\Mapping\ExtendingClass', $id);
$this->assertInstanceOf('\Doctrine\Tests\Models\Mapping\ExtendingClass', $doc);
$this->assertEquals('test test test', $doc->headline);
$this->assertEquals('Superclass test', $doc->topic);
}
}