Skip to content

Commit

Permalink
Merge pull request #25 from veelasky/patch
Browse files Browse the repository at this point in the history
Add More Test for basic model
  • Loading branch information
veelasky committed May 10, 2022
2 parents 22e4235 + c8d26c3 commit e77e46c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
11 changes: 11 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
comment:
layout: "reach, diff, flags"
require_changes: true
11 changes: 11 additions & 0 deletions tests/Models/BasicModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Tests\Models;

use Illuminate\Database\Eloquent\Model;

class BasicModel extends Model
{
protected $table = 'hashid_test';
protected static $unguarded = true;
}
6 changes: 1 addition & 5 deletions tests/Models/HashModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

namespace Tests\Models;

use Illuminate\Database\Eloquent\Model;
use Veelasky\LaravelHashId\Eloquent\HashableId;

class HashModel extends Model
class HashModel extends BasicModel
{
use HashableId;

protected $table = 'hashid_test';
protected static $unguarded = true;
}
8 changes: 8 additions & 0 deletions tests/Unit/HashableIdModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
use Tests\Models\BasicModel;
use Tests\Models\CustomKeyModel;
use Tests\Models\CustomSaltModel;
use Tests\Models\HashModel;
Expand Down Expand Up @@ -181,6 +182,13 @@ public function test_route_binding()

$resolved = $m->resolveRouteBinding($m->hash);
$this->assertTrue($resolved->is($m));

// revert to original
$m = new BasicModel();
$m->save();

$resolved = $m->resolveRouteBinding($m->getKey());
$this->assertTrue($resolved->is($m));
}

protected function getRepository(): Repository
Expand Down

0 comments on commit e77e46c

Please sign in to comment.