|
@@ 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 |
|
{ |
|
@@ 99-106 (lines=8) @@
|
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
|
| 99 |
|
public function testDeleteReturnsTrueWhenModelIsSuccessfullyRemovedFromDatabase() |
| 100 |
|
{ |
| 101 |
|
$this->databaseConnection->shouldReceive('prepare')->once()->andReturn($this->sqlStatement); |
| 102 |
|
$this->sqlStatement->shouldReceive('execute'); |
| 103 |
|
$this->sqlStatement->shouldReceive('rowCount')->once()->andReturn(1); |
| 104 |
|
|
| 105 |
|
$this->assertEquals(true, $this->model->delete(1)); |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
public function testDeleteReturnsFalseWhenModelWasNotDeletedFromDatabase() |
| 109 |
|
{ |
|
@@ 108-115 (lines=8) @@
|
| 105 |
|
$this->assertEquals(true, $this->model->delete(1)); |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
public function testDeleteReturnsFalseWhenModelWasNotDeletedFromDatabase() |
| 109 |
|
{ |
| 110 |
|
$this->databaseConnection->shouldReceive('prepare')->once()->andReturn($this->sqlStatement); |
| 111 |
|
$this->sqlStatement->shouldReceive('execute'); |
| 112 |
|
$this->sqlStatement->shouldReceive('rowCount')->once()->andReturn(0); |
| 113 |
|
|
| 114 |
|
$this->assertEquals(false, $this->model->delete(1)); |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
} |