testNewInstanceCreatesInstanceWithoutAttributes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 8
rs 9.4286
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
/**
4
 * @package A simple ORM that performs basic CRUD operations
5
 * @author Surajudeen AKANDE <[email protected]>
6
 * @license MIT <https://opensource.org/licenses/MIT>
7
 * @link http://www.github.com/andela-sakande
8
 * */
9
namespace Sirolad\Test;
10
11
use Mockery;
12
use Sirolad\Potato;
13
use Sirolad\Test\PotatoStub;
14
15
class PotatoTest extends \PHPUnit_Framework_TestCase
16
{
17
    /**
18
     * Tear down all mock objects
19
     */
20
    public function tearDown()
21
    {
22
        Mockery::close();
23
    }
24
25
    /**
26
     * Test that the exact tablename is returned
27
    **/
28
    public function testTableName()
29
    {
30
        $potato = new Potato();
31
        $this->assertInternalType("string", $potato->tableName());
32
    }
33
34
    /**
35
     * Test delete from database
36
    **/
37
    public function testDestroy()
38
    {
39
        $mock = Mockery::mock('Sirolad\Test\PotatoStub');
40
        $mock->shouldReceive('destroy')->with(1)->andReturn(true);
41
    }
42
43
    /**
44
     * Test find from database
45
    **/
46
    public function testFind()
47
    {
48
        $mock = Mockery::mock('Sirolad\Test\PotatoStub');
49
        $mock->shouldReceive('find')->with(1)->andReturn('foo');
50
    }
51
52
    /**
53
     * Test that instantiated class are without attributes
54
    **/
55
    public function testNewInstanceCreatesInstanceWithoutAttributes()
56
    {
57
        $instance = new PotatoStub();
58
        $this->assertEmpty($instance->getRecord());
59
        $this->assertEquals(0, sizeof($instance->getRecord()));
60
        $this->assertEquals(0, count($instance->getRecord()));
61
        $this->assertArrayNotHasKey('id', $instance->getRecord());
62
    }
63
64
    /**
65
     * Test class can be instantiated
66
    **/
67
    public function save()
68
    {
69
        $mock = Mockery::mock('Sirolad\Test\PotatoStub');
70
        $mock->shouldReceive('save')->with(1)->andReturn(true);
71
    }
72
}
73