Completed
Branch master (beb88f)
by Mohamed
05:11 queued 03:39
created

CardTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetTitle() 0 10 1
A testIsActive() 0 10 1
A testShortCardTitle() 0 7 1
A testUniqueCardSlug() 0 15 1
1
<?php
2
3
/*
4
 * This file is part of the Moo\FlashCard package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Moo\FlashCard\Tests\Entity;
13
14
use Moo\FlashCard\Tests\BaseTestCase;
15
16
/**
17
 * CardTest contains test cases for the Card entity class.
18
 *
19
 * @author Mohamed Alsharaf <[email protected]>
20
 */
21
class CardTest extends BaseTestCase
22
{
23
    public function testGetTitle()
24
    {
25
        // Create a card
26
        $card = $this->card();
27
28
        // Assert that the card is created
29
        $this->assertEquals('Cool card', $card->title);
30
        $this->assertEquals('cool-card', $card->slug);
31
        $this->assertEmpty($card->meta_description);
32
    }
33
34
    public function testIsActive()
35
    {
36
        // Create inactive card
37
        $card = $this->card([
38
            'active' => false,
39
        ]);
40
41
        // Assert the card is inactive
42
        $this->assertFalse((bool)$card->active);
43
    }
44
45
    /**
46
     * @expectedException   InvalidArgumentException
47
     */
48
    public function testShortCardTitle()
49
    {
50
        // Attempt to create a card with short title - expect an exception
51
        $this->card([
52
            'title' => 'Card',
53
        ]);
54
    }
55
56
    public function testUniqueCardSlug()
57
    {
58
        // Create a card
59
        $card1 = $this->card([
60
            'title' => 'Card one',
61
        ]);
62
63
        // Create another card with same title
64
        $card2 = $this->card([
65
            'title' => 'Card one',
66
        ]);
67
68
        // Assert that the slug is not equals
69
        $this->assertNotEquals($card2->slug, $card1->slug);
70
    }
71
}
72