Skip to content

Commit bbf5a5a

Browse files
committed
Merge branch 'master' into 5.5
2 parents 137db81 + ce6e638 commit bbf5a5a

File tree

8 files changed

+65
-75
lines changed

8 files changed

+65
-75
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
install:
89
- composer update

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"require-dev": {
2323
"phpunit/phpunit": "^6.0",
24-
"mockery/mockery": "^0.9",
24+
"mockery/mockery": "^1.0",
2525
"illuminated/testing-tools": "5.5.*"
2626
},
2727
"autoload": {

composer.lock

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

tests/HelperFunctions/TestCase.php

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,24 @@
44

55
use Illuminated\Testing\TestingTools;
66
use Mockery;
7+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
8+
9+
Mockery::globalHelpers();
710

811
abstract class TestCase extends \PHPUnit\Framework\TestCase
912
{
1013
use TestingTools;
14+
use MockeryPHPUnitIntegration;
1115

1216
public static $functions;
1317

1418
protected function setUp()
1519
{
16-
self::$functions = Mockery::mock();
17-
}
18-
19-
protected function shouldReceiveExecCallOnceWith($with)
20-
{
21-
self::$functions->shouldReceive('exec')->with($with)->once();
20+
self::$functions = mock();
2221
}
2322

24-
protected function tearDown()
23+
protected function expectsExecWith($command)
2524
{
26-
Mockery::close();
25+
self::$functions->expects()->exec($command);
2726
}
2827
}

tests/HelperFunctions/artisan/CallInBackgroundTest.php

+12-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Illuminated\Helpers\HelperFunctions\Tests\Artisan;
44

55
use Illuminated\Helpers\HelperFunctions\Tests\TestCase;
6-
use Mockery;
76

87
/**
98
* @runTestsInSeparateProcesses
@@ -14,39 +13,39 @@ class CallInBackgroundTest extends TestCase
1413
/** @test */
1514
public function it_works_without_optional_before_and_after_parameters()
1615
{
17-
$mock = Mockery::mock('alias:Illuminated\Helpers\Artisan\Command');
18-
$mock->shouldReceive('factory')->withArgs(['test command', null, null])->once()->andReturnSelf();
19-
$mock->shouldReceive('runInBackground')->withNoArgs()->once();
16+
$mock = mock('alias:Illuminated\Helpers\Artisan\Command');
17+
$mock->expects()->factory('test command', null, null)->andReturnSelf();
18+
$mock->expects()->runInBackground();
2019

2120
call_in_background('test command');
2221
}
2322

2423
/** @test */
2524
public function it_works_with_optional_before_parameter()
2625
{
27-
$mock = Mockery::mock('alias:Illuminated\Helpers\Artisan\Command');
28-
$mock->shouldReceive('factory')->withArgs(['test command', 'before command', null])->once()->andReturnSelf();
29-
$mock->shouldReceive('runInBackground')->withNoArgs()->once();
26+
$mock = mock('alias:Illuminated\Helpers\Artisan\Command');
27+
$mock->expects()->factory('test command', 'before command', null)->andReturnSelf();
28+
$mock->expects()->runInBackground();
3029

3130
call_in_background('test command', 'before command');
3231
}
3332

3433
/** @test */
3534
public function it_works_with_optional_after_parameter()
3635
{
37-
$mock = Mockery::mock('alias:Illuminated\Helpers\Artisan\Command');
38-
$mock->shouldReceive('factory')->withArgs(['test command', null, 'after command'])->once()->andReturnSelf();
39-
$mock->shouldReceive('runInBackground')->withNoArgs()->once();
36+
$mock = mock('alias:Illuminated\Helpers\Artisan\Command');
37+
$mock->expects()->factory('test command', null, 'after command')->andReturnSelf();
38+
$mock->expects()->runInBackground();
4039

4140
call_in_background('test command', null, 'after command');
4241
}
4342

4443
/** @test */
4544
public function it_works_with_optional_before_and_after_parameters_together()
4645
{
47-
$mock = Mockery::mock('alias:Illuminated\Helpers\Artisan\Command');
48-
$mock->shouldReceive('factory')->withArgs(['test command', 'before', 'after'])->once()->andReturnSelf();
49-
$mock->shouldReceive('runInBackground')->withNoArgs()->once();
46+
$mock = mock('alias:Illuminated\Helpers\Artisan\Command');
47+
$mock->expects()->factory('test command', 'before', 'after')->andReturnSelf();
48+
$mock->expects()->runInBackground();
5049

5150
call_in_background('test command', 'before', 'after');
5251
}

tests/HelperFunctions/classes/Artisan/CommandTest.php

+7-8
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
namespace Illuminated\Helpers\Artisan;
44

55
use Illuminated\Helpers\HelperFunctions\Tests\TestCase;
6-
use Mockery;
76

87
class CommandTest extends TestCase
98
{
109
protected function setUp()
1110
{
1211
parent::setUp();
1312

14-
$phpBinaryMock = Mockery::mock('overload:Symfony\Component\Process\PhpExecutableFinder');
15-
$phpBinaryMock->shouldReceive('find')->withNoArgs()->once()->andReturn('php');
13+
$phpBinaryMock = mock('overload:Symfony\Component\Process\PhpExecutableFinder');
14+
$phpBinaryMock->expects()->find()->andReturn('php');
1615
}
1716

1817
/** @test */
@@ -32,7 +31,7 @@ public function it_has_static_constructor_named_factory()
3231
/** @test */
3332
public function it_can_run_command_in_background()
3433
{
35-
$this->shouldReceiveExecCallOnceWith('(php artisan test:command) > /dev/null 2>&1 &');
34+
$this->expectsExecWith('(php artisan test:command) > /dev/null 2>&1 &');
3635

3736
$command = Command::factory('test:command');
3837
$command->runInBackground();
@@ -41,7 +40,7 @@ public function it_can_run_command_in_background()
4140
/** @test */
4241
public function run_in_background_supports_before_subcommand()
4342
{
44-
$this->shouldReceiveExecCallOnceWith('(before command && php artisan test:command) > /dev/null 2>&1 &');
43+
$this->expectsExecWith('(before command && php artisan test:command) > /dev/null 2>&1 &');
4544

4645
$command = Command::factory('test:command', 'before command');
4746
$command->runInBackground();
@@ -50,7 +49,7 @@ public function run_in_background_supports_before_subcommand()
5049
/** @test */
5150
public function run_in_background_supports_after_subcommand()
5251
{
53-
$this->shouldReceiveExecCallOnceWith('(php artisan test:command && after command) > /dev/null 2>&1 &');
52+
$this->expectsExecWith('(php artisan test:command && after command) > /dev/null 2>&1 &');
5453

5554
$command = Command::factory('test:command', null, 'after command');
5655
$command->runInBackground();
@@ -59,7 +58,7 @@ public function run_in_background_supports_after_subcommand()
5958
/** @test */
6059
public function run_in_background_supports_before_and_after_subcommands_together()
6160
{
62-
$this->shouldReceiveExecCallOnceWith('(before && php artisan test:command && after) > /dev/null 2>&1 &');
61+
$this->expectsExecWith('(before && php artisan test:command && after) > /dev/null 2>&1 &');
6362

6463
$command = Command::factory('test:command', 'before', 'after');
6564
$command->runInBackground();
@@ -72,7 +71,7 @@ public function run_in_background_supports_before_and_after_subcommands_together
7271
*/
7372
public function it_supports_overriding_of_artisan_binary_through_constant()
7473
{
75-
$this->shouldReceiveExecCallOnceWith('(before && php custom-artisan test:command && after) > /dev/null 2>&1 &');
74+
$this->expectsExecWith('(before && php custom-artisan test:command && after) > /dev/null 2>&1 &');
7675

7776
define('ARTISAN_BINARY', 'custom-artisan');
7877
$command = Command::factory('test:command', 'before', 'after');

tests/HelperFunctions/db/DbMysqlNowTest.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@
33
namespace Illuminated\Helpers\HelperFunctions\Tests\Db;
44

55
use Illuminated\Helpers\HelperFunctions\Tests\TestCase;
6-
use Mockery;
76

87
class DbMysqlNowTest extends TestCase
98
{
109
/** @test */
1110
public function it_returns_valid_mysql_datetime()
1211
{
13-
$mock = Mockery::mock('alias:Illuminate\Support\Facades\DB');
14-
$mock->shouldReceive('selectOne')->withArgs(['select now() as now'])->once()->andReturnUsing(function () {
15-
return (object) ['now' => '2016-09-17 18:49:46'];
16-
});
12+
$mock = mock('alias:Illuminate\Support\Facades\DB');
13+
$mock->expects()->selectOne('select now() as now')->andReturn((object) ['now' => '2016-09-17 18:49:46']);
1714

1815
$this->assertEquals('2016-09-17 18:49:46', db_mysql_now());
1916
}

tests/HelperFunctions/db/DbMysqlVariableTest.php

+5-13
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,24 @@
33
namespace Illuminated\Helpers\HelperFunctions\Tests\Db;
44

55
use Illuminated\Helpers\HelperFunctions\Tests\TestCase;
6-
use Mockery;
76

87
class DbMysqlVariableTest extends TestCase
98
{
109
/** @test */
1110
public function it_returns_false_for_unexisting_mysql_variable()
1211
{
13-
$mock = Mockery::mock('alias:Illuminate\Support\Facades\DB');
14-
$mock->shouldReceive('selectOne')
15-
->withArgs(['show variables where variable_name = ?', ['fake']])
16-
->once()
17-
->andReturnNull();
12+
$mock = mock('alias:Illuminate\Support\Facades\DB');
13+
$mock->expects()->selectOne('show variables where variable_name = ?', ['fake'])->andReturnNull();
1814

1915
$this->assertFalse(db_mysql_variable('fake'));
2016
}
2117

2218
/** @test */
2319
public function it_returns_value_for_existing_mysql_variable()
2420
{
25-
$mock = Mockery::mock('alias:Illuminate\Support\Facades\DB');
26-
$mock->shouldReceive('selectOne')
27-
->withArgs(['show variables where variable_name = ?', ['hostname']])
28-
->once()
29-
->andReturnUsing(function () {
30-
return (object) ['Variable_name' => 'hostname', 'Value' => 'localhost'];
31-
});
21+
$mock = mock('alias:Illuminate\Support\Facades\DB');
22+
$mock->expects()->selectOne('show variables where variable_name = ?', ['hostname'])
23+
->andReturn((object) ['Variable_name' => 'hostname', 'Value' => 'localhost']);
3224

3325
$this->assertEquals('localhost', db_mysql_variable('hostname'));
3426
}

0 commit comments

Comments
 (0)