-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do not perform update/delete without primary key. fixes #10
- Loading branch information
Paul M. Jones
committed
Sep 7, 2020
1 parent
5fe5987
commit 2d2a2be
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
use Atlas\Testing\CompositeDataSourceFixture; | ||
use Atlas\Testing\DataSource\Employee\EmployeeRow; | ||
use Atlas\Testing\DataSource\Employee\EmployeeTable; | ||
use Atlas\Testing\DataSource\Nopkey\NopkeyRow; | ||
use Atlas\Testing\DataSource\Nopkey\NopkeyTable; | ||
use Atlas\Testing\DataSourceFixture; | ||
use PDO; | ||
use PDOStatement; | ||
|
@@ -389,4 +391,36 @@ protected function silenceErrors() | |
$conn = $this->table->getWriteConnection(); | ||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); | ||
} | ||
|
||
public function testUpdateRow_noPrimaryKey() | ||
{ | ||
$table = $this->tableLocator->get(NopkeyTable::CLASS); | ||
$row = $table->newRow([ | ||
'name' => 'Bolivar Shagnasty', | ||
'email' => '[email protected]', | ||
]); | ||
$table->insertRow($row); | ||
|
||
$row->email = '[email protected]'; | ||
$this->expectException(Exception::CLASS); | ||
$this->expectExceptionMessage("Cannot update row on table 'nopkeys' without primary key."); | ||
|
||
$table->updateRow($row); | ||
} | ||
|
||
public function testDeleteRow_noPrimaryKey() | ||
{ | ||
$table = $this->tableLocator->get(NopkeyTable::CLASS); | ||
$row = $table->newRow([ | ||
'name' => 'Bolivar Shagnasty', | ||
'email' => '[email protected]', | ||
]); | ||
$table->insertRow($row); | ||
|
||
$row->email = '[email protected]'; | ||
$this->expectException(Exception::CLASS); | ||
$this->expectExceptionMessage("Cannot delete row on table 'nopkeys' without primary key."); | ||
|
||
$table->deleteRow($row); | ||
} | ||
} |