Skip to content

Commit 6eab6f2

Browse files
author
Reza Shadman
committed
Add test for faster model.
1 parent 7dfb57e commit 6eab6f2

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/FasterModelTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php namespace Reshadman\EloquentFaster\Tests;
2+
3+
use Reshadman\EloquentFaster\FasterModel;
4+
5+
class FasterModelTest extends \PHPUnit_Framework_TestCase {
6+
7+
public function test_get_cached_attributes_method()
8+
{
9+
FasterModel::cacheMutatedAttributes(User::class);
10+
11+
$this->assertTrue(isset(FasterModel::getCachedMutatorAttributes()[User::class]));
12+
13+
$this->assertContains('url', FasterModel::getCachedMutatorAttributes()[User::class]);
14+
}
15+
16+
public function test_load_array_from_cache()
17+
{
18+
$array = [
19+
User::class => [
20+
'url'
21+
]
22+
];
23+
24+
FasterModel::loadArrayIntoCachedMutatorAttributes($array);
25+
26+
$this->assertEquals(FasterModel::getCachedMutatorAttributes(), $array);
27+
}
28+
29+
}
30+
31+
32+
class User extends FasterModel {
33+
34+
public function getUrlAttribute()
35+
{
36+
37+
}
38+
39+
}

0 commit comments

Comments
 (0)