-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NullObjectFactoryTest.php
34 lines (28 loc) · 1.08 KB
/
NullObjectFactoryTest.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
<?php
/**
* This file is part of the guanguans/laravel-proxy-manager.
*
* (c) guanguans <[email protected]>
*
* This source file is subject to the MIT license that is bundled.
*/
namespace Guanguans\LaravelProxyManagerTests\Facades;
use Guanguans\LaravelProxyManager\Facades\NullObjectFactory;
use Guanguans\LaravelProxyManagerTests\TestClasses\NullObjectTestClass;
use ProxyManager\Proxy\NullObjectInterface;
it('will return `NullObject` proxy', function (): void {
$proxy = NullObjectFactory::createProxy(NullObjectTestClass::class);
expect($proxy)
->toBeInstanceOf(NullObjectTestClass::class)
->toBeInstanceOf(NullObjectInterface::class);
$proxy = NullObjectFactory::createProxy(new NullObjectTestClass(1));
expect($proxy)
->toBeInstanceOf(NullObjectTestClass::class)
->toBeInstanceOf(NullObjectInterface::class);
});
it('will throw TypeError', function (): void {
$proxy = NullObjectFactory::createProxy(new NullObjectTestClass(1));
expect($proxy)
->and($proxy->getId())
->toBeNull();
})->throws(\TypeError::class);