From 415d00ad6ecd6a6c85136dea6c446e21e9cba7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Monnot=20St=C3=A9phane?= Date: Wed, 24 Feb 2016 17:59:57 +0100 Subject: [PATCH 1/6] Fix value of 0 for primary key with non increment primary key --- src/Eloquent/Continent.php | 7 +++++++ src/Eloquent/Country.php | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Eloquent/Continent.php b/src/Eloquent/Continent.php index 2a1c196..5db15e0 100644 --- a/src/Eloquent/Continent.php +++ b/src/Eloquent/Continent.php @@ -4,6 +4,13 @@ class Continent extends Model { + /** + * Indicates if the IDs are auto-incrementing. + * + * @var bool + */ + public $incrementing = false; + /** * The table associated with the model. * diff --git a/src/Eloquent/Country.php b/src/Eloquent/Country.php index b6546e5..35dec15 100644 --- a/src/Eloquent/Country.php +++ b/src/Eloquent/Country.php @@ -4,6 +4,13 @@ class Country extends Model { + /** + * Indicates if the IDs are auto-incrementing. + * + * @var bool + */ + public $incrementing = false; + /** * The table associated with the model. * @@ -30,4 +37,4 @@ public function names() return $this->hasMany('Ipalaus\Geonames\Eloquent\Name'); } -} \ No newline at end of file +} From a33ed975f5b7ab8b7ed60bbf017ac29f34d28bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Monnot=20St=C3=A9phane?= Date: Fri, 26 Feb 2016 01:20:47 +0100 Subject: [PATCH 2/6] Fix phpunit tests errors --- composer.json | 1 + src/Commands/ImportCommand.php | 2 +- src/Commands/InstallCommand.php | 2 +- tests/ImportCommandTest.php | 24 ++++++++++++++++++++++++ tests/InstallCommandTest.php | 12 ++++++++++++ tests/TruncateCommandTest.php | 9 +++++++++ 6 files changed, 48 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e2840ab..f213d62 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "symfony/process": "2.8.*|3.0.*" }, "require-dev": { + "laravel/framework": ">=5.1.0", "mockery/mockery": "~0.9.2", "phpunit/phpunit": "~4.1" }, diff --git a/src/Commands/ImportCommand.php b/src/Commands/ImportCommand.php index 4e446da..5a65353 100644 --- a/src/Commands/ImportCommand.php +++ b/src/Commands/ImportCommand.php @@ -250,7 +250,7 @@ protected function seedCommand($class, $extra = '') */ protected function makeProcess($command) { - return new Process($command, $this->laravel['path.base'], null, null, 0); + return new Process($command, $this->laravel->basePath(), null, null, 0); } /** diff --git a/src/Commands/InstallCommand.php b/src/Commands/InstallCommand.php index ce82964..ea0e648 100644 --- a/src/Commands/InstallCommand.php +++ b/src/Commands/InstallCommand.php @@ -30,7 +30,7 @@ public function fire() { $force = $this->input->getOption('force'); - $path = $this->laravel['path.base'].'/app/config/packages/ipalaus/geonames/config.php'; + $path = $this->laravel->basePath().'/app/config/packages/ipalaus/geonames/config.php'; // prevents config overwrites if ($this->configExists($path) and ! $force) diff --git a/tests/ImportCommandTest.php b/tests/ImportCommandTest.php index eba2b7d..1e84e48 100644 --- a/tests/ImportCommandTest.php +++ b/tests/ImportCommandTest.php @@ -1,6 +1,7 @@ getRepo()), $this->getFiles(), array()); + + $app = new Application(); + $command->setLaravel($app); + $this->runCommand($command, array('--development' => true, '--country' => 'IP')); } @@ -21,6 +26,10 @@ public function testDevelopmentAndCountryCantBeBothOptions() public function testMustProvideAValidIsoAlpha2Country() { $command = new ImportCommandTestStub(new Importer($this->getRepo()), $this->getFiles(), array()); + + $app = new Application(); + $command->setLaravel($app); + $this->runCommand($command, array('--country' => 'Isern')); } @@ -78,6 +87,9 @@ public function testCommandCall() $command = $this->getMock('ImportCommandTestStub', $mockedMethods, array($importer, $filesystem, $config)); + $app = new Application(); + $command->setLaravel($app); + $filesystem->shouldReceive('isDirectory')->once()->andReturn(false); $filesystem->shouldReceive('makeDirectory')->once()->andReturn(true); $filesystem->shouldReceive('runProcess')->andReturn(null); @@ -114,6 +126,9 @@ public function testCommandAllFilesExistsCall() $command = $this->getMock('ImportCommandTestStub', $mockedMethods, array($importer, $filesystem, $config)); + $app = new Application(); + $command->setLaravel($app); + $filesystem->shouldReceive('isDirectory')->once()->andReturn(false); $filesystem->shouldReceive('makeDirectory')->once()->andReturn(true); $filesystem->shouldReceive('runProcess')->andReturn(null); @@ -147,6 +162,9 @@ public function testFetchOnlyOptionCall() $command = $this->getMock('ImportCommandTestStub', $mockedMethods, array($importer, $filesystem, $config)); + $app = new Application(); + $command->setLaravel($app); + $filesystem->shouldReceive('isDirectory')->once()->andReturn(false); $filesystem->shouldReceive('makeDirectory')->once()->andReturn(true); @@ -183,6 +201,9 @@ public function testDevelopmentOptionCall() $command = $this->getMock('ImportCommandTestStub', $mockedMethods, array($importer, $filesystem, $config)); + $app = new Application(); + $command->setLaravel($app); + $filesystem->shouldReceive('isDirectory')->once()->andReturn(false); $filesystem->shouldReceive('makeDirectory')->once()->andReturn(true); $filesystem->shouldReceive('runProcess')->andReturn(null); @@ -220,6 +241,9 @@ public function testCountryOptionCall() $command = $this->getMock('ImportCommandTestStub', $mockedMethods, array($importer, $filesystem, $config)); + $app = new Application(); + $command->setLaravel($app); + $filesystem->shouldReceive('isDirectory')->once()->andReturn(false); $filesystem->shouldReceive('makeDirectory')->once()->andReturn(true); $filesystem->shouldReceive('runProcess')->andReturn(null); diff --git a/tests/InstallCommandTest.php b/tests/InstallCommandTest.php index 8b4f833..0e6c014 100644 --- a/tests/InstallCommandTest.php +++ b/tests/InstallCommandTest.php @@ -1,5 +1,6 @@ setLaravel($app); + $this->runCommand($command); } @@ -17,6 +21,10 @@ public function testCommandCall() public function testExistingConfigThrowsException() { $command = $this->getMock('InstallCommandTestStub', array('configExists')); + + $app = new Application(); + $command->setLaravel($app); + $command->expects($this->once()) ->method('configExists') ->will($this->returnValue(true)); @@ -27,6 +35,10 @@ public function testExistingConfigThrowsException() public function testForceEvenConfigExists() { $command = $this->getMock('InstallCommandTestStub', array('configExists')); + + $app = new Application(); + $command->setLaravel($app); + $command->expects($this->once()) ->method('configExists') ->will($this->returnValue(true)); diff --git a/tests/TruncateCommandTest.php b/tests/TruncateCommandTest.php index f5bc194..5027e20 100644 --- a/tests/TruncateCommandTest.php +++ b/tests/TruncateCommandTest.php @@ -1,6 +1,7 @@ method('truncate'); $command = $this->getMock('TruncateCommandTestStub', array('confirmTruncate'), array($repo)); + + $app = new Application(); + $command->setLaravel($app); + $command->expects($this->once()) ->method('confirmTruncate') ->will($this->returnValue(true)); @@ -35,6 +40,10 @@ public function testExistingConfigThrowsException() $repo = $this->getMock('Ipalaus\Geonames\RepositoryInterface'); $command = $this->getMock('TruncateCommandTestStub', array('confirmTruncate'), array($repo)); + + $app = new Application(); + $command->setLaravel($app); + $command->expects($this->once()) ->method('confirmTruncate') ->will($this->returnValue(false)); From 3a8ad9e5b4f40575f01ef9ba7c2cbd458b0e786c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Monnot=20St=C3=A9phane?= Date: Fri, 26 Feb 2016 01:51:45 +0100 Subject: [PATCH 3/6] Fix migration filenames --- ...ames.php => 2013_11_28_170337_create_geonames_names_table.php} | 0 ...> 2013_11_28_170817_create_geonames_alternate_names_table.php} | 0 ....php => 2013_11_28_171326_create_geonames_countries_table.php} | 0 ...=> 2013_11_28_172716_create_geonames_language_codes_table.php} | 0 ...> 2013_11_28_173418_create_geonames_admin_divisions_table.php} | 0 ...013_11_28_173425_create_geonames_admin_subdivisions_table.php} | 0 ...hp => 2013_11_28_173636_create_geonames_hierarchies_table.php} | 0 ...s.php => 2013_11_28_173817_create_geonames_features_table.php} | 0 ....php => 2013_11_28_173936_create_geonames_timezones_table.php} | 0 ...php => 2013_11_28_174249_create_geonames_continents_table.php} | 0 ...=> 2014_05_08_230644_geonames_timezones_new_columns_table.php} | 0 ...4_06_09_204419_geonames_admin_divisions_longer_code_table.php} | 0 ...> 2014_06_10_165833_geonames_defaults_and_nullables_table.php} | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename src/migrations/{2013_11_28_170337_create_geonames_names.php => 2013_11_28_170337_create_geonames_names_table.php} (100%) rename src/migrations/{2013_11_28_170817_create_geonames_alternate_names.php => 2013_11_28_170817_create_geonames_alternate_names_table.php} (100%) rename src/migrations/{2013_11_28_171326_create_geonames_countries.php => 2013_11_28_171326_create_geonames_countries_table.php} (100%) rename src/migrations/{2013_11_28_172716_create_geonames_language_codes.php => 2013_11_28_172716_create_geonames_language_codes_table.php} (100%) rename src/migrations/{2013_11_28_173418_create_geonames_admin_divisions.php => 2013_11_28_173418_create_geonames_admin_divisions_table.php} (100%) rename src/migrations/{2013_11_28_173425_create_geonames_admin_subdivisions.php => 2013_11_28_173425_create_geonames_admin_subdivisions_table.php} (100%) rename src/migrations/{2013_11_28_173636_create_geonames_hierarchies.php => 2013_11_28_173636_create_geonames_hierarchies_table.php} (100%) rename src/migrations/{2013_11_28_173817_create_geonames_features.php => 2013_11_28_173817_create_geonames_features_table.php} (100%) rename src/migrations/{2013_11_28_173936_create_geonames_timezones.php => 2013_11_28_173936_create_geonames_timezones_table.php} (100%) rename src/migrations/{2013_11_28_174249_create_geonames_continents.php => 2013_11_28_174249_create_geonames_continents_table.php} (100%) rename src/migrations/{2014_05_08_230644_geonames_timezones_new_columns.php => 2014_05_08_230644_geonames_timezones_new_columns_table.php} (100%) rename src/migrations/{2014_06_09_204419_geonames_admin_divisions_longer_code.php => 2014_06_09_204419_geonames_admin_divisions_longer_code_table.php} (100%) rename src/migrations/{2014_06_10_165833_geonames_defaults_and_nullables.php => 2014_06_10_165833_geonames_defaults_and_nullables_table.php} (100%) diff --git a/src/migrations/2013_11_28_170337_create_geonames_names.php b/src/migrations/2013_11_28_170337_create_geonames_names_table.php similarity index 100% rename from src/migrations/2013_11_28_170337_create_geonames_names.php rename to src/migrations/2013_11_28_170337_create_geonames_names_table.php diff --git a/src/migrations/2013_11_28_170817_create_geonames_alternate_names.php b/src/migrations/2013_11_28_170817_create_geonames_alternate_names_table.php similarity index 100% rename from src/migrations/2013_11_28_170817_create_geonames_alternate_names.php rename to src/migrations/2013_11_28_170817_create_geonames_alternate_names_table.php diff --git a/src/migrations/2013_11_28_171326_create_geonames_countries.php b/src/migrations/2013_11_28_171326_create_geonames_countries_table.php similarity index 100% rename from src/migrations/2013_11_28_171326_create_geonames_countries.php rename to src/migrations/2013_11_28_171326_create_geonames_countries_table.php diff --git a/src/migrations/2013_11_28_172716_create_geonames_language_codes.php b/src/migrations/2013_11_28_172716_create_geonames_language_codes_table.php similarity index 100% rename from src/migrations/2013_11_28_172716_create_geonames_language_codes.php rename to src/migrations/2013_11_28_172716_create_geonames_language_codes_table.php diff --git a/src/migrations/2013_11_28_173418_create_geonames_admin_divisions.php b/src/migrations/2013_11_28_173418_create_geonames_admin_divisions_table.php similarity index 100% rename from src/migrations/2013_11_28_173418_create_geonames_admin_divisions.php rename to src/migrations/2013_11_28_173418_create_geonames_admin_divisions_table.php diff --git a/src/migrations/2013_11_28_173425_create_geonames_admin_subdivisions.php b/src/migrations/2013_11_28_173425_create_geonames_admin_subdivisions_table.php similarity index 100% rename from src/migrations/2013_11_28_173425_create_geonames_admin_subdivisions.php rename to src/migrations/2013_11_28_173425_create_geonames_admin_subdivisions_table.php diff --git a/src/migrations/2013_11_28_173636_create_geonames_hierarchies.php b/src/migrations/2013_11_28_173636_create_geonames_hierarchies_table.php similarity index 100% rename from src/migrations/2013_11_28_173636_create_geonames_hierarchies.php rename to src/migrations/2013_11_28_173636_create_geonames_hierarchies_table.php diff --git a/src/migrations/2013_11_28_173817_create_geonames_features.php b/src/migrations/2013_11_28_173817_create_geonames_features_table.php similarity index 100% rename from src/migrations/2013_11_28_173817_create_geonames_features.php rename to src/migrations/2013_11_28_173817_create_geonames_features_table.php diff --git a/src/migrations/2013_11_28_173936_create_geonames_timezones.php b/src/migrations/2013_11_28_173936_create_geonames_timezones_table.php similarity index 100% rename from src/migrations/2013_11_28_173936_create_geonames_timezones.php rename to src/migrations/2013_11_28_173936_create_geonames_timezones_table.php diff --git a/src/migrations/2013_11_28_174249_create_geonames_continents.php b/src/migrations/2013_11_28_174249_create_geonames_continents_table.php similarity index 100% rename from src/migrations/2013_11_28_174249_create_geonames_continents.php rename to src/migrations/2013_11_28_174249_create_geonames_continents_table.php diff --git a/src/migrations/2014_05_08_230644_geonames_timezones_new_columns.php b/src/migrations/2014_05_08_230644_geonames_timezones_new_columns_table.php similarity index 100% rename from src/migrations/2014_05_08_230644_geonames_timezones_new_columns.php rename to src/migrations/2014_05_08_230644_geonames_timezones_new_columns_table.php diff --git a/src/migrations/2014_06_09_204419_geonames_admin_divisions_longer_code.php b/src/migrations/2014_06_09_204419_geonames_admin_divisions_longer_code_table.php similarity index 100% rename from src/migrations/2014_06_09_204419_geonames_admin_divisions_longer_code.php rename to src/migrations/2014_06_09_204419_geonames_admin_divisions_longer_code_table.php diff --git a/src/migrations/2014_06_10_165833_geonames_defaults_and_nullables.php b/src/migrations/2014_06_10_165833_geonames_defaults_and_nullables_table.php similarity index 100% rename from src/migrations/2014_06_10_165833_geonames_defaults_and_nullables.php rename to src/migrations/2014_06_10_165833_geonames_defaults_and_nullables_table.php From 1f3f54c694c6523047baf3572a072e4daa325b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Monnot=20St=C3=A9phane?= Date: Fri, 26 Feb 2016 01:57:00 +0100 Subject: [PATCH 4/6] Fix non-abstract DatabaseSeeder class error --- src/Seeders/DatabaseSeeder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Seeders/DatabaseSeeder.php b/src/Seeders/DatabaseSeeder.php index 03295b3..5a2799a 100644 --- a/src/Seeders/DatabaseSeeder.php +++ b/src/Seeders/DatabaseSeeder.php @@ -3,7 +3,7 @@ use Ipalaus\Geonames\Importer; use Illuminate\Database\Seeder; -class DatabaseSeeder extends Seeder { +abstract class DatabaseSeeder extends Seeder { /** * The importer instance. @@ -23,4 +23,4 @@ public function __construct(Importer $importer) $this->importer = $importer; } -} \ No newline at end of file +} From 1655b5ef4401009c96b466d89cc03147c6cfd619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Monnot=20St=C3=A9phane?= Date: Fri, 26 Feb 2016 02:02:02 +0100 Subject: [PATCH 5/6] Fix wrong declaration of the method line in CommandTestStub classes --- tests/ImportCommandTest.php | 2 +- tests/TruncateCommandTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ImportCommandTest.php b/tests/ImportCommandTest.php index 1e84e48..a24b898 100644 --- a/tests/ImportCommandTest.php +++ b/tests/ImportCommandTest.php @@ -355,7 +355,7 @@ public function call($command, array $arguments = array()) // } - public function line($string) + public function line($string, $style = null, $verbosity = null) { // } diff --git a/tests/TruncateCommandTest.php b/tests/TruncateCommandTest.php index 5027e20..3c01d44 100644 --- a/tests/TruncateCommandTest.php +++ b/tests/TruncateCommandTest.php @@ -67,7 +67,7 @@ protected function getMethod($name) { class TruncateCommandTestStub extends TruncateCommand { - public function line($string) + public function line($string, $style = null, $verbosity = null) { // } From 4561f60d4371c7b4ad0608408ec4d192b6f0ed28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Monnot=20St=C3=A9phane?= Date: Fri, 26 Feb 2016 02:12:34 +0100 Subject: [PATCH 6/6] Remove php 5.4 from travis file --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 44f9a4e..afb85a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.4 - 5.5 - 5.6 @@ -11,4 +10,4 @@ before_script: script: phpunit -c phpunit.xml --coverage-text after_script: - - php vendor/bin/coveralls -v \ No newline at end of file + - php vendor/bin/coveralls -v