Skip to content

Commit 4589088

Browse files
authored
Merge pull request #31 from candasm/php_54_class_name_bug_fix
Update mockery mock class names for php 54.
2 parents e2cf6d1 + 8d7bfd9 commit 4589088

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

tests/Unit/ElasticsearchServiceProviderUnitTest.php

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,60 @@
22
namespace Shift31\LaravelElasticsearch\Tests\Unit;
33

44
use Mockery;
5-
use Elasticsearch\Client;
65
use Mockery\MockInterface;
7-
use Illuminate\Config\Repository;
8-
use Illuminate\Filesystem\Filesystem;
96
use Illuminate\Foundation\AliasLoader;
10-
use Illuminate\Foundation\Application;
117
use Shift31\LaravelElasticsearch\Tests\TestCase;
128
use Shift31\LaravelElasticsearch\ElasticsearchServiceProvider;
139

1410
class ElasticsearchServiceProviderUnitTest extends TestCase
1511
{
1612
public function test_it_should_provide_elasticsearch()
1713
{
18-
$provider = new ElasticsearchServiceProvider(Mockery::mock(Application::class));
14+
$provider = new ElasticsearchServiceProvider(Mockery::mock('Illuminate\Foundation\Application'));
1915
$this->assertEquals(['elasticsearch'], $provider->provides());
2016
}
2117

2218
public function test_boot_method_to_set_config_file()
2319
{
2420
$configPath = realpath($this->getSourcePath('config'));
25-
$filesMock = Mockery::mock(Filesystem::class, function (MockInterface $m) use ($configPath) {
21+
$filesMock = Mockery::mock('Illuminate\Filesystem\Filesystem', function (MockInterface $m) use ($configPath) {
2622
$m->shouldReceive('isDirectory')->with($configPath)->once()->andReturn(true);
2723
$m->shouldReceive('isDirectory')->withAnyArgs()->times(3)->andReturn(false);
2824
});
29-
$configMock = Mockery::mock(Repository::class, function (MockInterface $m) use ($configPath) {
25+
$configMock = Mockery::mock('Illuminate\Config\Repository', function (MockInterface $m) use ($configPath) {
3026
$m->shouldReceive('package')
3127
->with('shift31/laravel-elasticsearch', $configPath, 'laravel-elasticsearch')
3228
->once()
3329
->andReturnSelf();
3430
});
35-
$application = Mockery::mock(Application::class, function (MockInterface $m) use ($configMock, $filesMock) {
36-
$m->shouldReceive('offsetGet')->with('config')->once()->andReturn($configMock);
37-
$m->shouldReceive('offsetGet')->with('files')->times(4)->andReturn($filesMock);
38-
$m->shouldReceive('offsetGet')->with('path')->once()->andReturn($this->getSourcePath());
39-
});
31+
$application = Mockery::mock('Illuminate\Foundation\Application',
32+
function (MockInterface $m) use ($configMock, $filesMock) {
33+
$m->shouldReceive('offsetGet')->with('config')->once()->andReturn($configMock);
34+
$m->shouldReceive('offsetGet')->with('files')->times(4)->andReturn($filesMock);
35+
$m->shouldReceive('offsetGet')->with('path')->once()->andReturn($this->getSourcePath());
36+
});
4037
$provider = new ElasticsearchServiceProvider($application);
4138
$this->assertNull($provider->boot());
4239
}
4340

4441
public function test_register_method_to_set_singleton_elastic_search_client()
4542
{
4643
$configPath = $this->getSourcePath('config/elasticsearch.php');
47-
$configMock = Mockery::mock(Repository::class, function (MockInterface $m) {
44+
$configMock = Mockery::mock('Illuminate\Config\Repository', function (MockInterface $m) {
4845
$m->shouldReceive('get')->with('elasticsearch')->andReturn([]);
4946
});
50-
$filesMock = Mockery::mock(Filesystem::class, function (MockInterface $m) use ($configPath) {
47+
$filesMock = Mockery::mock('Illuminate\Filesystem\Filesystem', function (MockInterface $m) use ($configPath) {
5148
$m->shouldReceive('getRequire')
5249
->with($configPath)
5350
->once()->andReturn([]);
5451
});
55-
$application = Mockery::mock(Application::class, function (MockInterface $m) use ($configMock, $filesMock) {
52+
$application = Mockery::mock('Illuminate\Foundation\Application', function (MockInterface $m) use ($configMock, $filesMock) {
5653
$m->shouldReceive('booting')->once()->andReturnSelf();
5754
$m->shouldReceive('offsetGet')->with('config')->andReturn($configMock);
5855
$m->shouldReceive('offsetGet')->with('files')->andReturn($filesMock);
5956
$m->shouldReceive('singleton')->with('elasticsearch',
6057
Mockery::on(function ($closure) {
61-
$this->assertInstanceOf(Client::class, $closure());
58+
$this->assertInstanceOf('Elasticsearch\Client', $closure());
6259

6360
return true;
6461
}))->once()->andReturnSelf();
@@ -69,7 +66,7 @@ public function test_register_method_to_set_singleton_elastic_search_client()
6966

7067
public function test_register_method_to_set_elastic_search_facade()
7168
{
72-
$application = Mockery::mock(Application::class, function (MockInterface $m) {
69+
$application = Mockery::mock('Illuminate\Foundation\Application', function (MockInterface $m) {
7370
$m->shouldReceive('singleton')->once()->andReturnSelf();
7471
$m->shouldReceive('booting')->with(Mockery::on(function ($closure) {
7572
$closure();

tests/Unit/EsUnitTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
use Mockery;
55
use ReflectionClass;
6-
use Illuminate\Foundation\Application;
76
use Shift31\LaravelElasticsearch\Facades\Es;
87
use Shift31\LaravelElasticsearch\Tests\TestCase;
98
use Shift31\LaravelElasticsearch\ElasticsearchServiceProvider;
@@ -15,7 +14,7 @@ public function test_to_facade_accessor_matches_service_provider()
1514
$class = new ReflectionClass(new Es());
1615
$method = $class->getMethod('getFacadeAccessor');
1716
$method->setAccessible(true);
18-
$provider = new ElasticsearchServiceProvider(Mockery::mock(Application::class));
17+
$provider = new ElasticsearchServiceProvider(Mockery::mock('Illuminate\Foundation\Application'));
1918
$this->assertEquals($provider->provides(), (array)$method->invoke(new Es()));
2019
}
2120
}

0 commit comments

Comments
 (0)