|
@@ 61-69 (lines=9) @@
|
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
public function testGetReturnNullWhenIdNotFoundInDatabase() |
| 62 |
|
{ |
| 63 |
|
$this->databaseConnection->shouldReceive('prepare')->once()->andReturn($this->sqlStatement); |
| 64 |
|
$this->sqlStatement->shouldReceive('setFetchMode'); |
| 65 |
|
$this->sqlStatement->shouldReceive('execute'); |
| 66 |
|
$this->sqlStatement->shouldReceive('rowCount')->once()->andReturn(0); |
| 67 |
|
|
| 68 |
|
$this->assertEquals(null, $this->model->get(1)); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
public function testAllReturnsAnArrayOfObjectsWhenValuesAreInDatabase() |
| 72 |
|
{ |
|
@@ 125-132 (lines=8) @@
|
| 122 |
|
$this->assertEquals($values, $this->model->getProperties()); |
| 123 |
|
} |
| 124 |
|
|
| 125 |
|
public function testDeleteReturnsTrueWhenModelIsSuccessfullyRemovedFromDatabase() |
| 126 |
|
{ |
| 127 |
|
$this->databaseConnection->shouldReceive('prepare')->once()->andReturn($this->sqlStatement); |
| 128 |
|
$this->sqlStatement->shouldReceive('execute'); |
| 129 |
|
$this->sqlStatement->shouldReceive('rowCount')->once()->andReturn(1); |
| 130 |
|
|
| 131 |
|
$this->assertEquals(true, $this->model->delete(1)); |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
public function testDeleteReturnsFalseWhenModelWasNotDeletedFromDatabase() |
| 135 |
|
{ |
|
@@ 134-141 (lines=8) @@
|
| 131 |
|
$this->assertEquals(true, $this->model->delete(1)); |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
public function testDeleteReturnsFalseWhenModelWasNotDeletedFromDatabase() |
| 135 |
|
{ |
| 136 |
|
$this->databaseConnection->shouldReceive('prepare')->once()->andReturn($this->sqlStatement); |
| 137 |
|
$this->sqlStatement->shouldReceive('execute'); |
| 138 |
|
$this->sqlStatement->shouldReceive('rowCount')->once()->andReturn(0); |
| 139 |
|
|
| 140 |
|
$this->assertEquals(false, $this->model->delete(1)); |
| 141 |
|
} |
| 142 |
|
|
| 143 |
|
public function testMagicMethodsReturnCorrectResult() |
| 144 |
|
{ |