/
MockProviderTest.php
68 lines (56 loc) · 1.67 KB
/
MockProviderTest.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Laradev\Test\Support\Traits;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Foundation\Application;
use Laradev\Test\Support\TestCase;
use Mockery\MockInterface;
final class MockProviderTest extends TestCase
{
public function testNewMock()
{
$this->assertInstanceOf(MockInterface::class, $this->newMock());
$this->assertInstanceOf(Application::class, $this->newMock(Application::class));
}
public function testNewAppMock()
{
$this->assertInstanceOf(Application::class, $this->newAppMock());
}
public function testNewConfigMock()
{
$this->assertInstanceOf(Repository::class, $this->newConfigMock());
}
public function testMockingFunctions()
{
$arg1 = 'something';
$arg2 = 'else';
$this->newFunctionMock('callme')
->with($arg1, $arg2)
->andReturn(true);
function callme($arg1, $arg2)
{
return MockProviderTest::useFunction('callme', $arg1, $arg2);
}
$this->assertTrue(callme($arg1, $arg2));
}
public function testNewAppContainerWithConfigMock()
{
$app = $this->newAppContainerWithConfigMock();
$this->assertInstanceOf(Container::class, $app);
$this->assertInstanceOf(MockInterface::class, $app['config']);
}
/**
* {@inheritdoc}
*/
protected function doSetUp()
{
}
/**
* {@inheritdoc}
*/
protected function doTearDown()
{
$this->releaseMocks();
$this->assertNull(self::$functions);
}
}