-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from warren32/fix/morph-map-to-class
Get actual class name from morph map
- Loading branch information
Showing
2 changed files
with
20 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
<?php | ||
|
||
use Mockery as m; | ||
use Carbon\Carbon; | ||
use Mpociot\Versionable\Version; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Config; | ||
use Mockery as m; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Mpociot\Versionable\Version; | ||
use Mpociot\Versionable\VersionableTrait; | ||
use Illuminate\Database\Eloquent\Relations\Relation; | ||
|
||
class VersionableTest extends VersionableTestCase | ||
{ | ||
|
@@ -513,6 +514,21 @@ public function testAllowHiddenFields() { | |
|
||
$this->assertArrayNotHasKey('password', $user->toArray()); | ||
} | ||
|
||
public function testWhereModelHasMorphMap() | ||
{ | ||
Relation::morphMap(['users' => TestVersionableUser::class]); | ||
$user = new TestVersionableUser(); | ||
$user->name = "Test"; | ||
$user->email = "[email protected]"; | ||
$user->password = "12345"; | ||
$user->last_login = $user->freshTimestamp(); | ||
$user->save(); | ||
|
||
$version = $user->currentVersion(); | ||
$this->assertEquals( $user->attributesToArray(), $version->getModel()->attributesToArray() ); | ||
Relation::morphMap([], false); | ||
} | ||
|
||
} | ||
|
||
|