Skip to content
This repository was archived by the owner on Nov 26, 2021. It is now read-only.

Commit a33ed97

Browse files
Fix phpunit tests errors
1 parent 415d00a commit a33ed97

6 files changed

Lines changed: 48 additions & 2 deletions

File tree

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"symfony/process": "2.8.*|3.0.*"
2626
},
2727
"require-dev": {
28+
"laravel/framework": ">=5.1.0",
2829
"mockery/mockery": "~0.9.2",
2930
"phpunit/phpunit": "~4.1"
3031
},

src/Commands/ImportCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ protected function seedCommand($class, $extra = '')
250250
*/
251251
protected function makeProcess($command)
252252
{
253-
return new Process($command, $this->laravel['path.base'], null, null, 0);
253+
return new Process($command, $this->laravel->basePath(), null, null, 0);
254254
}
255255

256256
/**

src/Commands/InstallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function fire()
3030
{
3131
$force = $this->input->getOption('force');
3232

33-
$path = $this->laravel['path.base'].'/app/config/packages/ipalaus/geonames/config.php';
33+
$path = $this->laravel->basePath().'/app/config/packages/ipalaus/geonames/config.php';
3434

3535
// prevents config overwrites
3636
if ($this->configExists($path) and ! $force)

tests/ImportCommandTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Mockery as m;
4+
use Illuminate\Foundation\Application;
45
use Ipalaus\Geonames\Importer;
56
use Ipalaus\Geonames\Commands\ImportCommand;
67

@@ -12,6 +13,10 @@ class ImportCommandTest extends PHPUnit_Framework_TestCase {
1213
public function testDevelopmentAndCountryCantBeBothOptions()
1314
{
1415
$command = new ImportCommandTestStub(new Importer($this->getRepo()), $this->getFiles(), array());
16+
17+
$app = new Application();
18+
$command->setLaravel($app);
19+
1520
$this->runCommand($command, array('--development' => true, '--country' => 'IP'));
1621
}
1722

@@ -21,6 +26,10 @@ public function testDevelopmentAndCountryCantBeBothOptions()
2126
public function testMustProvideAValidIsoAlpha2Country()
2227
{
2328
$command = new ImportCommandTestStub(new Importer($this->getRepo()), $this->getFiles(), array());
29+
30+
$app = new Application();
31+
$command->setLaravel($app);
32+
2433
$this->runCommand($command, array('--country' => 'Isern'));
2534
}
2635

@@ -78,6 +87,9 @@ public function testCommandCall()
7887

7988
$command = $this->getMock('ImportCommandTestStub', $mockedMethods, array($importer, $filesystem, $config));
8089

90+
$app = new Application();
91+
$command->setLaravel($app);
92+
8193
$filesystem->shouldReceive('isDirectory')->once()->andReturn(false);
8294
$filesystem->shouldReceive('makeDirectory')->once()->andReturn(true);
8395
$filesystem->shouldReceive('runProcess')->andReturn(null);
@@ -114,6 +126,9 @@ public function testCommandAllFilesExistsCall()
114126

115127
$command = $this->getMock('ImportCommandTestStub', $mockedMethods, array($importer, $filesystem, $config));
116128

129+
$app = new Application();
130+
$command->setLaravel($app);
131+
117132
$filesystem->shouldReceive('isDirectory')->once()->andReturn(false);
118133
$filesystem->shouldReceive('makeDirectory')->once()->andReturn(true);
119134
$filesystem->shouldReceive('runProcess')->andReturn(null);
@@ -147,6 +162,9 @@ public function testFetchOnlyOptionCall()
147162

148163
$command = $this->getMock('ImportCommandTestStub', $mockedMethods, array($importer, $filesystem, $config));
149164

165+
$app = new Application();
166+
$command->setLaravel($app);
167+
150168
$filesystem->shouldReceive('isDirectory')->once()->andReturn(false);
151169
$filesystem->shouldReceive('makeDirectory')->once()->andReturn(true);
152170

@@ -183,6 +201,9 @@ public function testDevelopmentOptionCall()
183201

184202
$command = $this->getMock('ImportCommandTestStub', $mockedMethods, array($importer, $filesystem, $config));
185203

204+
$app = new Application();
205+
$command->setLaravel($app);
206+
186207
$filesystem->shouldReceive('isDirectory')->once()->andReturn(false);
187208
$filesystem->shouldReceive('makeDirectory')->once()->andReturn(true);
188209
$filesystem->shouldReceive('runProcess')->andReturn(null);
@@ -220,6 +241,9 @@ public function testCountryOptionCall()
220241

221242
$command = $this->getMock('ImportCommandTestStub', $mockedMethods, array($importer, $filesystem, $config));
222243

244+
$app = new Application();
245+
$command->setLaravel($app);
246+
223247
$filesystem->shouldReceive('isDirectory')->once()->andReturn(false);
224248
$filesystem->shouldReceive('makeDirectory')->once()->andReturn(true);
225249
$filesystem->shouldReceive('runProcess')->andReturn(null);

tests/InstallCommandTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Illuminate\Foundation\Application;
34
use Ipalaus\Geonames\Commands\InstallCommand;
45

56
class InstallCommandTest extends PHPUnit_Framework_TestCase {
@@ -8,6 +9,9 @@ public function testCommandCall()
89
{
910
$command = new InstallCommandTestStub;
1011

12+
$app = new Application();
13+
$command->setLaravel($app);
14+
1115
$this->runCommand($command);
1216
}
1317

@@ -17,6 +21,10 @@ public function testCommandCall()
1721
public function testExistingConfigThrowsException()
1822
{
1923
$command = $this->getMock('InstallCommandTestStub', array('configExists'));
24+
25+
$app = new Application();
26+
$command->setLaravel($app);
27+
2028
$command->expects($this->once())
2129
->method('configExists')
2230
->will($this->returnValue(true));
@@ -27,6 +35,10 @@ public function testExistingConfigThrowsException()
2735
public function testForceEvenConfigExists()
2836
{
2937
$command = $this->getMock('InstallCommandTestStub', array('configExists'));
38+
39+
$app = new Application();
40+
$command->setLaravel($app);
41+
3042
$command->expects($this->once())
3143
->method('configExists')
3244
->will($this->returnValue(true));

tests/TruncateCommandTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Mockery as m;
4+
use Illuminate\Foundation\Application;
45
use Ipalaus\Geonames\Commands\TruncateCommand;
56

67
class TruncateCommandTest extends PHPUnit_Framework_TestCase {
@@ -12,6 +13,10 @@ public function testCommandCall()
1213
->method('truncate');
1314

1415
$command = $this->getMock('TruncateCommandTestStub', array('confirmTruncate'), array($repo));
16+
17+
$app = new Application();
18+
$command->setLaravel($app);
19+
1520
$command->expects($this->once())
1621
->method('confirmTruncate')
1722
->will($this->returnValue(true));
@@ -35,6 +40,10 @@ public function testExistingConfigThrowsException()
3540
$repo = $this->getMock('Ipalaus\Geonames\RepositoryInterface');
3641

3742
$command = $this->getMock('TruncateCommandTestStub', array('confirmTruncate'), array($repo));
43+
44+
$app = new Application();
45+
$command->setLaravel($app);
46+
3847
$command->expects($this->once())
3948
->method('confirmTruncate')
4049
->will($this->returnValue(false));

0 commit comments

Comments
 (0)