forked from mongodb/laravel-mongodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPropertyTest.php
38 lines (29 loc) · 1 KB
/
PropertyTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
declare(strict_types=1);
namespace MongoDB\Laravel\Tests\Eloquent;
use MongoDB\Laravel\Tests\Models\HiddenAnimal;
use MongoDB\Laravel\Tests\TestCase;
use function assert;
final class PropertyTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
HiddenAnimal::truncate();
}
public function testCanHideCertainProperties(): void
{
HiddenAnimal::create([
'name' => 'Sheep',
'country' => 'Ireland',
'can_be_eaten' => true,
]);
$hiddenAnimal = HiddenAnimal::sole();
assert($hiddenAnimal instanceof HiddenAnimal);
self::assertSame('Ireland', $hiddenAnimal->country);
self::assertTrue($hiddenAnimal->can_be_eaten);
self::assertArrayHasKey('name', $hiddenAnimal->toArray());
self::assertArrayNotHasKey('country', $hiddenAnimal->toArray(), 'the country column should be hidden');
self::assertArrayHasKey('can_be_eaten', $hiddenAnimal->toArray());
}
}