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 ed352e7 commit 2b03f7a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
declare(strict_types=1);
namespace LeanOrm\Exceptions;

class BadRecordClassNameForFetchingRelatedDataException extends \Exception{}
2 changes: 1 addition & 1 deletion src/LeanOrm/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ protected function validateRelatedRecordClassName(string $record_class_name): bo
. PHP_EOL . static::class . '::' . __FUNCTION__ . '(...).'
. PHP_EOL;

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

return true;
Expand Down
8 changes: 4 additions & 4 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function testThatBelongsToThrowsExceptionWithInvalidForeignModelClassName

public function testThatBelongsToThrowsExceptionWithInvalidForeignRecordClassName() {

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

$model = new $this->modelClass(static::$dsn, static::$username ?? "", static::$password ?? "", [],'comment_id', 'comments');
// relation name with the same name as p key column
Expand Down Expand Up @@ -313,7 +313,7 @@ public function testThatHasOneThrowsExceptionWithInvalidForeignModelClassName()

public function testThatHasOneThrowsExceptionWithInvalidForeignRecordClassName() {

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

$model = new $this->modelClass(static::$dsn, static::$username ?? "", static::$password ?? "", [],'comment_id', 'comments');
$model->hasOne(
Expand Down Expand Up @@ -439,7 +439,7 @@ public function testThatHasManyThrowsExceptionWithInvalidForeignModelClassName()

public function testThatHasManyThrowsExceptionWithInvalidForeignRecordClassName() {

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

$model = new $this->modelClass(static::$dsn, static::$username ?? "", static::$password ?? "", [],'comment_id', 'comments');
$model->hasMany(
Expand Down Expand Up @@ -567,7 +567,7 @@ public function testThatHasManyThroughThrowsExceptionWithInvalidForeignModelClas

public function testThatHasManyThroughThrowsExceptionWithInvalidForeignRecordClassName() {

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

$model = new $this->modelClass(static::$dsn, static::$username ?? "", static::$password ?? "", [],'post_id', 'posts');
$model->hasManyThrough(
Expand Down

0 comments on commit 2b03f7a

Please sign in to comment.