Code Duplication    Length = 8-9 lines in 4 locations

test/ModelTest.php 4 locations

@@ 58-66 (lines=9) @@
55
    /**
56
     * @expectedException Pyjac\ORM\Exception\ModelNotFoundException
57
     */
58
    public function testGetThrowsModelNotFoundExceptionWhenIdNotFoundInDatabase()
59
    {
60
    	$this->databaseConnection->shouldReceive('prepare')->once()->andReturn($this->sqlStatement);
61
    	$this->sqlStatement->shouldReceive('setFetchMode');
62
    	$this->sqlStatement->shouldReceive('execute');
63
    	$this->sqlStatement->shouldReceive('rowCount')->once()->andReturn(0);
64
    	
65
    	$this->assertInstanceOf('stdClass', $this->model->get(1));
66
    }
67
68
    public function testAllReturnsAnArrayOfObjectsWhenValuesAreInDatabase()
69
    {
@@ 96-103 (lines=8) @@
93
    	$this->assertEquals(1, $this->model->create());
94
    }
95
96
    public function testSaveShouldCreateNewModelInDatabaseWhenIdNotPresent()
97
    {
98
    	$this->model->setProperties(['name' => 'pyjac', 'age' => '419']);
99
    	$this->databaseConnection->shouldReceive('prepare')->once()->andReturn($this->sqlStatement);
100
    	$this->sqlStatement->shouldReceive('execute');
101
    	$this->sqlStatement->shouldReceive('rowCount')->once()->andReturn(1);
102
    	$this->assertEquals(1, $this->model->save());
103
    }
104
105
    public function testSaveShouldUpdateModelInDatabaseIfIdIsPresent()
106
    {
@@ 116-123 (lines=8) @@
113
114
115
116
    public function testDeleteReturnsTrueWhenModelIsSuccessfullyRemovedFromDatabase()
117
    {
118
    	$this->databaseConnection->shouldReceive('prepare')->once()->andReturn($this->sqlStatement);
119
    	$this->sqlStatement->shouldReceive('execute');
120
    	$this->sqlStatement->shouldReceive('rowCount')->once()->andReturn(1);
121
    	
122
    	$this->assertEquals(true, $this->model->delete(1));
123
    }
124
125
    public function testDeleteReturnsFalseWhenModelWasNotDeletedFromDatabase()
126
    {
@@ 125-132 (lines=8) @@
122
    	$this->assertEquals(true, $this->model->delete(1));
123
    }
124
125
    public function testDeleteReturnsFalseWhenModelWasNotDeletedFromDatabase()
126
    {
127
    	$this->databaseConnection->shouldReceive('prepare')->once()->andReturn($this->sqlStatement);
128
    	$this->sqlStatement->shouldReceive('execute');
129
    	$this->sqlStatement->shouldReceive('rowCount')->once()->andReturn(0);
130
    	
131
    	$this->assertEquals(false, $this->model->delete(1));
132
    }
133
134
    public function testMagicMethodsReturnCorrectResult() {
135
	    /*$this->model->setReturnValue('__get', 'Pyjac', array('name'));