Skip to content

Commit

Permalink
Use more specific exception
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Nov 6, 2016
1 parent a828fec commit 81e4c3f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function setUp()
$result = $customer->searchItems( $search );

if( ( $customerItem = reset( $result ) ) === false ) {
throw new \Exception( sprintf( 'No customer item found for code "%1$s"', 'UTC001' ) );
throw new \RuntimeException( sprintf( 'No customer item found for code "%1$s"', 'UTC001' ) );
}

$this->fixture = array(
Expand Down Expand Up @@ -103,7 +103,7 @@ public function testGetItem()
$items = $this->object->searchItems( $search );

if( ( $item = reset( $items ) ) === false ) {
throw new \Exception( 'No address item with company "ABC" found' );
throw new \RuntimeException( 'No address item with company "ABC" found' );
}

$this->assertEquals( $item, $this->object->getItem( $item->getId() ) );
Expand Down
2 changes: 1 addition & 1 deletion lib/custom/tests/MShop/Customer/Manager/FosUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testGetItem()
$items = $this->object->searchItems( $search, array( 'text' ) );

if( ( $expected = reset( $items ) ) === false ) {
throw new \Exception( 'No customer item with code "UTC003" found' );
throw new \RuntimeException( 'No customer item with code "UTC003" found' );
}

$actual = $this->object->getItem( $expected->getId(), array( 'text' ) );
Expand Down
22 changes: 11 additions & 11 deletions lib/custom/tests/MShop/Customer/Manager/Lists/FosUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testGetItem()
$results = $this->object->searchItems( $search );

if( ( $item = reset( $results ) ) === false ) {
throw new \Exception( 'No item found' );
throw new \RuntimeException( 'No item found' );
}

$this->assertEquals( $item, $this->object->getItem( $item->getId() ) );
Expand All @@ -91,7 +91,7 @@ public function testSaveUpdateDeleteItem()
$items = $this->object->searchItems( $search );

if( ( $item = reset( $items ) ) === false ) {
throw new \Exception( 'No item found' );
throw new \RuntimeException( 'No item found' );
}

$item->setId( null );
Expand Down Expand Up @@ -152,11 +152,11 @@ public function testMoveItemLastToFront()
$this->assertGreaterThan( 1, count( $listItems ) );

if( ( $first = reset( $listItems ) ) === false ) {
throw new \Exception( 'No first customer list item' );
throw new \RuntimeException( 'No first customer list item' );
}

if( ( $last = end( $listItems ) ) === false ) {
throw new \Exception( 'No last customer list item' );
throw new \RuntimeException( 'No last customer list item' );
}

$this->object->moveItem( $last->getId(), $first->getId() );
Expand All @@ -177,15 +177,15 @@ public function testMoveItemFirstToLast()
$this->assertGreaterThan( 1, count( $listItems ) );

if( ( $first = reset( $listItems ) ) === false ) {
throw new \Exception( 'No first customer list item' );
throw new \RuntimeException( 'No first customer list item' );
}

if( ( $second = next( $listItems ) ) === false ) {
throw new \Exception( 'No second customer list item' );
throw new \RuntimeException( 'No second customer list item' );
}

if( ( $last = end( $listItems ) ) === false ) {
throw new \Exception( 'No last customer list item' );
throw new \RuntimeException( 'No last customer list item' );
}

$this->object->moveItem( $first->getId() );
Expand All @@ -206,15 +206,15 @@ public function testMoveItemFirstUp()
$this->assertGreaterThan( 1, count( $listItems ) );

if( ( $first = reset( $listItems ) ) === false ) {
throw new \Exception( 'No first customer list item' );
throw new \RuntimeException( 'No first customer list item' );
}

if( ( $second = next( $listItems ) ) === false ) {
throw new \Exception( 'No second customer list item' );
throw new \RuntimeException( 'No second customer list item' );
}

if( ( $last = end( $listItems ) ) === false ) {
throw new \Exception( 'No last customer list item' );
throw new \RuntimeException( 'No last customer list item' );
}

$this->object->moveItem( $first->getId(), $last->getId() );
Expand Down Expand Up @@ -313,7 +313,7 @@ protected function getListItems()
$results = $manager->searchItems( $search );

if( ( $item = reset( $results ) ) === false ) {
throw new \Exception( 'No customer item found' );
throw new \RuntimeException( 'No customer item found' );
}

$search = $this->object->createSearch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testGetItem()
$results = $this->object->searchItems($search);

if( ( $expected = reset($results) ) === false ) {
throw new \Exception( 'No list type item found' );
throw new \RuntimeException( 'No list type item found' );
}

$this->assertEquals( $expected, $this->object->getItem( $expected->getId() ) );
Expand All @@ -90,7 +90,7 @@ public function testSaveUpdateDeleteItem()
$results = $this->object->searchItems($search);

if( ( $item = reset($results) ) === false ) {
throw new \Exception( 'No type item found' );
throw new \RuntimeException( 'No type item found' );
}

$item->setId(null);
Expand Down

0 comments on commit 81e4c3f

Please sign in to comment.