Skip to content

Commit

Permalink
Reorganizing Exceptions Namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
rotimi committed Feb 4, 2024
1 parent 955b247 commit 1353386
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
5 changes: 0 additions & 5 deletions src/LeanOrm/InvalidArgumentException.php

This file was deleted.

6 changes: 3 additions & 3 deletions src/LeanOrm/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ protected function throwExceptionForInvalidDeleteQueryArg(mixed $val, array $col
. PHP_EOL . var_export($cols_n_vals, true) . PHP_EOL
. PHP_EOL;

throw new InvalidArgumentException($msg);
throw new \LeanOrm\Exceptions\InvalidArgumentException($msg);
}

/**
Expand All @@ -1779,7 +1779,7 @@ public function deleteSpecifiedRecord(\GDAO\Model\RecordInterface $record): ?boo
. "using a Model instance of `%s` belonging to the database table `%s` in "
. static::class . '::' . __FUNCTION__ . '(...).'
. PHP_EOL .'Undeleted record: ' . PHP_EOL . var_export($record, true) . PHP_EOL;
throw new InvalidArgumentException(
throw new \LeanOrm\Exceptions\InvalidArgumentException(
sprintf(
$msg, $record::class, $record->getModel()::class,
$record->getModel()->getTableName(),
Expand Down Expand Up @@ -2282,7 +2282,7 @@ protected function throwExceptionForInvalidUpdateQueryArg(mixed $val, array $col
. PHP_EOL . var_export($cols_n_vals, true) . PHP_EOL
. PHP_EOL;

throw new InvalidArgumentException($msg);
throw new \LeanOrm\Exceptions\InvalidArgumentException($msg);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/LeanOrm/Model/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public function offsetSet(mixed $key, mixed $val): void {
. PHP_EOL . ' Key of type `' . get_debug_type($key) . '` given.'
. PHP_EOL . ' Specified key: '. var_export($val, true) . PHP_EOL;

throw new \LeanOrm\InvalidArgumentException($msg);
throw new \LeanOrm\Exceptions\InvalidArgumentException($msg);
}

if ($key === null) {
Expand Down
12 changes: 6 additions & 6 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ public function testThatDeleteMatchingDbTableThrowsExceptionWithUnacceptableDele
// acceptable insert values are
// *bool, *null, *number, *string, *object with __toString
// Any value outside of these is considered invalid for insert
$this->expectException(\LeanOrm\InvalidArgumentException::class);
$this->expectException(\LeanOrm\Exceptions\InvalidArgumentException::class);

$model = new $this->modelClass(static::$dsn, static::$username ?? "", static::$password ?? "", [], 'id', 'key_value');
$delete_query = [
Expand All @@ -801,7 +801,7 @@ public function testThatDeleteMatchingDbTableThrowsExceptionWithUnacceptableDele
// acceptable insert values are
// *bool, *null, *number, *string, *object with __toString
// Any value outside of these is considered invalid for insert
$this->expectException(\LeanOrm\InvalidArgumentException::class);
$this->expectException(\LeanOrm\Exceptions\InvalidArgumentException::class);

$model = new $this->modelClass(static::$dsn, static::$username ?? "", static::$password ?? "", [], 'id', 'key_value');
$delete_query = [
Expand Down Expand Up @@ -851,7 +851,7 @@ public function testThatDeleteSpecifiedRecordThrowsExceptionForReadOnlyRecords()

public function testThatDeleteSpecifiedRecordThrowsExceptionForRecordBelongingToADifferentModelClassButSameDbTable() {

$this->expectException(LeanOrm\InvalidArgumentException::class);
$this->expectException(\LeanOrm\Exceptions\InvalidArgumentException::class);

$authorsModel = new LeanOrm\TestObjects\AuthorsModel(static::$dsn, static::$username ?? "", static::$password ?? "");

Expand All @@ -863,7 +863,7 @@ public function testThatDeleteSpecifiedRecordThrowsExceptionForRecordBelongingTo

public function testThatDeleteSpecifiedRecordThrowsExceptionForRecordBelongingToADifferentDbTable() {

$this->expectException(LeanOrm\InvalidArgumentException::class);
$this->expectException(\LeanOrm\Exceptions\InvalidArgumentException::class);

$authorsModel = new LeanOrm\TestObjects\AuthorsModel(static::$dsn, static::$username ?? "", static::$password ?? "");

Expand Down Expand Up @@ -3495,7 +3495,7 @@ public function testThatUpdateMatchingDbTableRowsThrowsExceptionWithUnacceptable
// acceptable insert values are
// *bool, *null, *number, *string, *object with __toString
// Any value outside of these is considered invalid for insert
$this->expectException(\LeanOrm\InvalidArgumentException::class);
$this->expectException(\LeanOrm\Exceptions\InvalidArgumentException::class);

$model = new $this->modelClass(static::$dsn, static::$username ?? "", static::$password ?? "", [], 'id', 'key_value');
$update_vals = ['key_name' => 'Test Key New',];
Expand All @@ -3515,7 +3515,7 @@ public function testThatUpdateMatchingDbTableRowsThrowsExceptionWithUnacceptable
// acceptable insert values are
// *bool, *null, *number, *string, *object with __toString
// Any value outside of these is considered invalid for insert
$this->expectException(\LeanOrm\InvalidArgumentException::class);
$this->expectException(\LeanOrm\Exceptions\InvalidArgumentException::class);

$model = new $this->modelClass(static::$dsn, static::$username ?? "", static::$password ?? "", [], 'id', 'key_value');
$update_vals = ['key_name' => 'Test Key New',];
Expand Down

0 comments on commit 1353386

Please sign in to comment.