Passed
Push — master ( 88105a...84be9d )
by Alexey
17:21
created

LoadPostData::load()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 29
ccs 0
cts 24
cp 0
rs 8.8571
c 1
b 0
f 0
cc 1
eloc 20
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Skobkin\Bundle\PointToolsBundle\DataFixtures\ORM;
4
5
use Doctrine\Common\DataFixtures\AbstractFixture;
6
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7
use Doctrine\Common\Persistence\ObjectManager;
8
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post;
9
use Skobkin\Bundle\PointToolsBundle\Entity\User;
10
11
class LoadPostData extends AbstractFixture implements OrderedFixtureInterface
12
{
13
    public function load(ObjectManager $om)
14
    {
15
        /** @var User $testUser */
16
        $testUser = $this->getReference('test_user_99999');
17
18
        $longPost = (new Post('longpost'))
19
            ->setAuthor($testUser)
20
            ->setCreatedAt(new \DateTime())
21
            ->setText('Test post with many comments')
22
            ->setPrivate(false)
23
            ->setType(Post::TYPE_POST)
24
            ->setDeleted(false)
25
        ;
26
27
        $shortPost = (new Post('shortpost'))
28
            ->setAuthor($testUser)
29
            ->setCreatedAt(new \DateTime())
30
            ->setText('Test short post')
31
            ->setPrivate(false)
32
            ->setType(Post::TYPE_POST)
33
            ->setDeleted(false)
34
        ;
35
36
        $om->persist($longPost);
37
        $om->persist($shortPost);
38
        $om->flush();
39
40
        $this->addReference('test_post_longpost', $longPost);
41
    }
42
43
    public function getOrder()
44
    {
45
        return 2;
46
    }
47
}