Skip to content

Commit 99067e3

Browse files
committed
Merge branch 'master' into 5.5
2 parents f9aec9f + 1a001bb commit 99067e3

6 files changed

+62
-59
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: php
33
php:
44
- 7.0
55
- 7.1
6+
- 7.2
67

78
services:
89
- redis-server

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"require-dev": {
1919
"phpunit/phpunit": "^6.0",
20-
"mockery/mockery": "^0.9",
20+
"mockery/mockery": "^1.0",
2121
"orchestra/testbench": "3.5.*",
2222
"illuminated/testing-tools": "5.5.*",
2323
"predis/predis": "^1.1.1",

composer.lock

+36-35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/ConsoleMutex/MutexTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use GenericCommand;
66
use Illuminate\Support\Facades\Cache;
77
use Illuminated\Console\Mutex;
8-
use Mockery;
98
use NinjaMutex\Lock\FlockLock;
109
use NinjaMutex\Lock\MemcachedLock;
1110
use NinjaMutex\Lock\MySqlLock;
@@ -22,8 +21,8 @@ public function setUp()
2221
{
2322
parent::setUp();
2423

25-
$this->command = Mockery::mock(GenericCommand::class)->makePartial();
26-
$this->command->shouldReceive('argument')->withNoArgs()->andReturn(['foo' => 'bar']);
24+
$this->command = mock(GenericCommand::class)->makePartial();
25+
$this->command->expects()->argument()->andReturn(['foo' => 'bar']);
2726
}
2827

2928
/** @test */
@@ -43,7 +42,7 @@ public function it_determines_mutex_strategy_once_while_creation()
4342
/** @test */
4443
public function it_has_default_strategy_which_is_file()
4544
{
46-
$this->command->shouldReceive('getMutexStrategy')->withNoArgs()->once()->andReturn('foobar');
45+
$this->command->expects()->getMutexStrategy()->andReturn('foobar');
4746

4847
$mutex = new Mutex($this->command);
4948
$expectedStrategy = new FlockLock(storage_path('app'));
@@ -53,7 +52,7 @@ public function it_has_default_strategy_which_is_file()
5352
/** @test */
5453
public function it_supports_mysql_strategy()
5554
{
56-
$this->command->shouldReceive('getMutexStrategy')->withNoArgs()->once()->andReturn('mysql');
55+
$this->command->expects()->getMutexStrategy()->andReturn('mysql');
5756

5857
$mutex = new Mutex($this->command);
5958
$expectedStrategy = new MySqlLock(
@@ -68,7 +67,7 @@ public function it_supports_mysql_strategy()
6867
/** @test */
6968
public function it_supports_redis_strategy_with_predis_client_which_is_default()
7069
{
71-
$this->command->shouldReceive('getMutexStrategy')->withNoArgs()->once()->andReturn('redis');
70+
$this->command->expects()->getMutexStrategy()->andReturn('redis');
7271

7372
$mutex = new Mutex($this->command);
7473
$expectedStrategy = new PredisRedisLock($mutex->getPredisClient());
@@ -80,7 +79,7 @@ public function it_supports_redis_strategy_with_phpredis_client()
8079
{
8180
config(['database.redis.client' => 'phpredis']);
8281

83-
$this->command->shouldReceive('getMutexStrategy')->withNoArgs()->once()->andReturn('redis');
82+
$this->command->expects()->getMutexStrategy()->andReturn('redis');
8483

8584
$mutex = new Mutex($this->command);
8685
$expectedStrategy = new PhpRedisLock($mutex->getPhpRedisClient());
@@ -108,7 +107,8 @@ public function it_supports_memcached_strategy()
108107
{
109108
Cache::shouldReceive('getStore')->withNoArgs()->twice()->andReturnSelf();
110109
Cache::shouldReceive('getMemcached')->withNoArgs()->twice()->andReturnSelf();
111-
$this->command->shouldReceive('getMutexStrategy')->withNoArgs()->once()->andReturn('memcached');
110+
111+
$this->command->expects()->getMutexStrategy()->andReturn('memcached');
112112

113113
$mutex = new Mutex($this->command);
114114
$expectedStrategy = new MemcachedLock(Cache::getStore()->getMemcached());
@@ -122,8 +122,8 @@ public function it_supports_memcached_strategy()
122122
*/
123123
public function it_delegates_public_method_calls_to_ninja_mutex()
124124
{
125-
$ninja = Mockery::mock('overload:NinjaMutex\Mutex');
126-
$ninja->shouldReceive('isLocked')->once();
125+
$ninja = mock('overload:NinjaMutex\Mutex');
126+
$ninja->expects()->isLocked();
127127

128128
$mutex = new Mutex($this->command);
129129
$mutex->isLocked();

tests/ConsoleMutex/TestCase.php

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use Illuminate\Contracts\Console\Kernel as KernelContract;
66
use Illuminated\Testing\TestingTools;
77
use Kernel;
8+
use Mockery;
9+
10+
Mockery::globalHelpers();
811

912
abstract class TestCase extends \Orchestra\Testbench\TestCase
1013
{

tests/ConsoleMutex/WithoutOverlappingTraitTest.php

+11-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Illuminated\Console\ConsoleMutex\Tests;
44

55
use GenericCommand;
6-
use Mockery;
76
use MysqlStrategyCommand;
87
use NullTimeoutCommand;
98
use RuntimeException;
@@ -71,9 +70,9 @@ public function mutex_timeout_can_be_set_to_null_by_the_public_method()
7170
/** @test */
7271
public function it_generates_mutex_name_based_on_the_command_name_and_arguments()
7372
{
74-
$command = Mockery::mock(GenericCommand::class)->makePartial();
75-
$command->shouldReceive('getName')->withNoArgs()->once()->andReturn('icm:generic');
76-
$command->shouldReceive('argument')->withNoArgs()->once()->andReturn(['foo' => 'bar', 'baz' => 'faz']);
73+
$command = mock(GenericCommand::class)->makePartial();
74+
$command->expects()->getName()->andReturn('icm:generic');
75+
$command->expects()->argument()->andReturn(['foo' => 'bar', 'baz' => 'faz']);
7776

7877
$md5 = md5(json_encode(['foo' => 'bar', 'baz' => 'faz']));
7978
$this->assertEquals("icmutex-icm:generic-{$md5}", $command->getMutexName());
@@ -86,9 +85,9 @@ public function it_generates_mutex_name_based_on_the_command_name_and_arguments(
8685
*/
8786
public function it_allows_to_run_command_if_there_is_no_other_running_instances()
8887
{
89-
$mutex = Mockery::mock('overload:Illuminated\Console\Mutex');
90-
$mutex->shouldReceive('acquireLock')->with(0)->once()->andReturn(true);
91-
$mutex->shouldReceive('releaseLock')->withNoArgs();
88+
$mutex = mock('overload:Illuminated\Console\Mutex');
89+
$mutex->expects()->acquireLock(0)->andReturn(true);
90+
$mutex->allows()->releaseLock();
9291

9392
$this->artisan('icm:generic');
9493
}
@@ -100,11 +99,10 @@ public function it_allows_to_run_command_if_there_is_no_other_running_instances(
10099
*/
101100
public function it_blocks_if_trying_to_run_another_instance_of_the_command()
102101
{
103-
$mutex = Mockery::mock('overload:Illuminated\Console\Mutex');
104-
$mutex->shouldReceive('acquireLock')->with(0)->once()->andReturn(false);
102+
$mutex = mock('overload:Illuminated\Console\Mutex');
103+
$mutex->expects()->acquireLock(0)->andReturn(false);
105104

106-
$this->expectException(RuntimeException::class);
107-
$this->expectExceptionMessage('Command is running now!');
105+
$this->willSeeException(RuntimeException::class, 'Command is running now!');
108106

109107
$this->artisan('icm:generic');
110108
}
@@ -116,8 +114,8 @@ public function it_blocks_if_trying_to_run_another_instance_of_the_command()
116114
*/
117115
public function it_is_releasing_the_lock_after_command_execution()
118116
{
119-
$mutex = Mockery::mock('overload:Illuminated\Console\Mutex');
120-
$mutex->shouldReceive('releaseLock')->withNoArgs()->once();
117+
$mutex = mock('overload:Illuminated\Console\Mutex');
118+
$mutex->expects()->releaseLock();
121119

122120
$command = new GenericCommand;
123121
$command->releaseMutexLock($mutex);

0 commit comments

Comments
 (0)