From d34aa0100043362390a2fad1fbca7ab145a72e95 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 20 Nov 2020 20:49:22 -0500 Subject: [PATCH] Fix APIv4 test to assert an exception is thrown The test had only run its assertion in the catch block which would have been skipped if an exception wasn't thrown --- tests/phpunit/api/v4/Action/ContactGetTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/api/v4/Action/ContactGetTest.php b/tests/phpunit/api/v4/Action/ContactGetTest.php index 7524a2db8399..649928815ed1 100644 --- a/tests/phpunit/api/v4/Action/ContactGetTest.php +++ b/tests/phpunit/api/v4/Action/ContactGetTest.php @@ -88,12 +88,14 @@ public function testGetWithLimit() { $limit2 = Contact::get(FALSE)->setLimit(2)->addSelect('sort_name', 'row_count')->execute(); $this->assertCount(2, (array) $limit2); $this->assertCount($num, $limit2); + $msg = ''; try { $limit2->single(); } catch (\API_Exception $e) { - $this->assertRegExp(';Expected to find one Contact record;', $e->getMessage()); + $msg = $e->getMessage(); } + $this->assertRegExp(';Expected to find one Contact record;', $msg); $limit1 = Contact::get(FALSE)->setLimit(1)->execute(); $this->assertCount(1, (array) $limit1); $this->assertCount(1, $limit1);