summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMitch <[email protected]>2014-06-19 22:25:08 +1000
committerMitch <[email protected]>2014-06-19 22:25:08 +1000
commit90469df2980ff338e91fb23a514d24a135e3147b (patch)
treeaf9e3fae4fdb73a3b1905fd2b483a3b2e7872e41 /test
parent2aa5869fa6a6c27216077731974fc025f8a14df3 (diff)
Update tests to not expect generic exception, as PHPUnit < 3.7 (PHP 5.2) can't handle it
Diffstat (limited to 'test')
-rw-r--r--test/ORMTest.php101
1 files changed, 55 insertions, 46 deletions
diff --git a/test/ORMTest.php b/test/ORMTest.php
index 3df3a73..f244f12 100644
--- a/test/ORMTest.php
+++ b/test/ORMTest.php
@@ -101,8 +101,6 @@ class ORMTest extends PHPUnit_Framework_TestCase {
}
/**
- * @expectedException Exception
- * @expectedExceptionMessage Primary key ID missing from row or is null
* These next two tests are needed because if you have select()ed some fields,
* but not the primary key, then the primary key is not available for the
* update/delete query - see issue #203.
@@ -110,61 +108,72 @@ class ORMTest extends PHPUnit_Framework_TestCase {
* becuase MockPDOStatement->fetch() always returns an id.
*/
public function testUpdateNullPrimaryKey() {
- $widget = ORM::for_table('widget')
- ->use_id_column('primary')
- ->select('foo')
- ->where('primary', 1)
- ->find_one()
- ;
+ try {
+ $widget = ORM::for_table('widget')
+ ->use_id_column('primary')
+ ->select('foo')
+ ->where('primary', 1)
+ ->find_one()
+ ;
- $widget->foo = 'bar';
- $widget->save();
+ $widget->foo = 'bar';
+ $widget->save();
+
+ throw new Exception('Test did not throw expected exception');
+ } catch (Exception $e) {
+ $this->assertEquals($e->getMessage(), 'Primary key ID missing from row or is null');
+ }
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Primary key ID missing from row or is null
- */
public function testDeleteNullPrimaryKey() {
- $widget = ORM::for_table('widget')
- ->use_id_column('primary')
- ->select('foo')
- ->where('primary', 1)
- ->find_one()
- ;
+ try {
+ $widget = ORM::for_table('widget')
+ ->use_id_column('primary')
+ ->select('foo')
+ ->where('primary', 1)
+ ->find_one()
+ ;
- $widget->delete();
+ $widget->delete();
+
+ throw new Exception('Test did not throw expected exception');
+ } catch (Exception $e) {
+ $this->assertEquals($e->getMessage(), 'Primary key ID missing from row or is null');
+ }
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Primary key ID missing from row or is null
- */
public function testNullPrimaryKey() {
- $widget = ORM::for_table('widget')
- ->use_id_column('primary')
- ->select('foo')
- ->where('primary', 1)
- ->find_one()
- ;
+ try {
+ $widget = ORM::for_table('widget')
+ ->use_id_column('primary')
+ ->select('foo')
+ ->where('primary', 1)
+ ->find_one()
+ ;
- $widget->id(true);
+ $widget->id(true);
+
+ throw new Exception('Test did not throw expected exception');
+ } catch (Exception $e) {
+ $this->assertEquals($e->getMessage(), 'Primary key ID missing from row or is null');
+ }
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Primary key ID contains null value(s)
- */
public function testNullPrimaryKeyPart() {
- $widget = ORM::for_table('widget')
- ->use_id_column(array('id', 'primary'))
- ->select('foo')
- ->where('id', 1)
- ->where('primary', 1)
- ->find_one()
- ;
-
- $widget->id(true);
-
+ try {
+ $widget = ORM::for_table('widget')
+ ->use_id_column(array('id', 'primary'))
+ ->select('foo')
+ ->where('id', 1)
+ ->where('primary', 1)
+ ->find_one()
+ ;
+
+ $widget->id(true);
+
+ throw new Exception('Test did not throw expected exception');
+ } catch (Exception $e) {
+ $this->assertEquals($e->getMessage(), 'Primary key ID contains null value(s)');
+ }
}
} \ No newline at end of file