BasePostTest_Post   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 7
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\NewsBundle\Tests\Model;
15
16
use PHPUnit\Framework\TestCase;
17
use Sonata\NewsBundle\Model\Post;
18
19
class BasePostTest_Post extends Post
20
{
21
    public function getId(): void
22
    {
23
        // TODO: Implement getId() method.
24
    }
25
}
26
27
class BasePostTest extends TestCase
28
{
29
    public function testIsCommentable(): void
30
    {
31
        $post = new BasePostTest_Post();
32
33
        $post->setEnabled(true);
34
        $post->setCommentsEnabled(false);
35
        $this->assertFalse($post->isCommentable());
36
37
        $post->setCommentsEnabled(true);
38
39
        $past = new \DateTime('-1 hour');
40
        $post->setCommentsCloseAt($past);
41
        $this->assertFalse($post->isCommentable());
42
43
        $futur = new \DateTime('+1 hour');
44
        $post->setCommentsCloseAt($futur);
45
        $this->assertTrue($post->isCommentable());
46
    }
47
48
    public function testIsPublic(): void
49
    {
50
        $post = new BasePostTest_Post();
51
52
        $post->setEnabled(true);
53
        $this->assertTrue($post->isPublic());
54
55
        $post->setEnabled(false);
56
        $this->assertFalse($post->isPublic());
57
58
        $post->setEnabled(true);
59
        $post->setPublicationDateStart(new \DateTime('+1 year'));
60
61
        $this->assertFalse($post->isPublic());
62
    }
63
64
    public function testSlug(): void
65
    {
66
        $post = new BasePostTest_Post();
67
68
        $post->setTitle('Salut Symfony2');
69
70
        $this->assertSame('salut-symfony2', $post->getSlug());
71
    }
72
}
73