Skip to content

Commit 0aefd99

Browse files
committed
Added testSecondLevelNestingEntity. A comment refers to another comment.
Moved test data insertion and mappings to setUpBeforeClass.
1 parent 1136071 commit 0aefd99

File tree

2 files changed

+271
-126
lines changed

2 files changed

+271
-126
lines changed

tests/Integrations/Doctrine/AbstractTestCase.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
use Doctrine\DBAL\Schema\SchemaException;
1010
use Doctrine\ORM\Tools\SchemaTool;
11+
use NilPortugues\Tests\Api\JsonApi\Integrations\Doctrine\Entity\Customer;
12+
use NilPortugues\Tests\Api\JsonApi\Integrations\Doctrine\Mappings\CustomerMapping;
13+
use NilPortugues\Tests\Api\JsonApi\Integrations\Doctrine\Mappings\PostMapping;
14+
use NilPortugues\Tests\Api\JsonApi\Integrations\Doctrine\Mappings\CommentMapping;
15+
use NilPortugues\Tests\Api\JsonApi\Integrations\Doctrine\Entity\Post;
16+
use NilPortugues\Tests\Api\JsonApi\Integrations\Doctrine\Entity\Comment;
1117

1218
require_once 'bootstrap.php';
1319

@@ -17,13 +23,44 @@ abstract class AbstractTestCase extends \PHPUnit_Framework_TestCase
1723
* @var \Doctrine\ORM\EntityManager
1824
*/
1925
protected static $entityManager;
26+
protected static $classConfig;
2027

2128
public static function setUpBeforeClass()
2229
{
2330
self::$entityManager = GetEntityManager();
2431
// Build the schema for sqlite
2532
self::generateSchema();
2633

34+
$newCustomer = new Customer();
35+
$newCustomer->setActive(true);
36+
$newCustomer->setName('Name 1');
37+
self::$entityManager->persist($newCustomer);
38+
39+
$newPost = new Post();
40+
$newPost->setCustomer($newCustomer);
41+
$newPost->setDate(new \DateTime('2016-07-12 16:30:12.000000'));
42+
$newPost->setDescription('Description test');
43+
self::$entityManager->persist($newPost);
44+
45+
$newComment = new Comment();
46+
$newComment->setPost($newPost);
47+
$newComment->setComment('Comment 1');
48+
self::$entityManager->persist($newComment);
49+
50+
$newComment2 = new Comment();
51+
$newComment2->setPost($newPost);
52+
$newComment2->setComment('Comment 2');
53+
$newComment2->setParentComment($newComment);
54+
self::$entityManager->persist($newComment2);
55+
56+
self::$entityManager->flush();
57+
58+
self::$classConfig = [
59+
CustomerMapping::class,
60+
PostMapping::class,
61+
CommentMapping::class,
62+
];
63+
2764
parent::setUpBeforeClass();
2865
}
2966

0 commit comments

Comments
 (0)