diff --git a/src/Publiux/laravelcdn/Commands/PushCommand.php b/src/Publiux/laravelcdn/Commands/PushCommand.php index ff64684..168a587 100644 --- a/src/Publiux/laravelcdn/Commands/PushCommand.php +++ b/src/Publiux/laravelcdn/Commands/PushCommand.php @@ -63,18 +63,13 @@ public function handle() $configurations = $this->helper->getConfigurations(); - if ($this->option('y')) { - $this->cdn->push(); - return; - } - if (!empty($configurations['providers']['aws']['s3']['upload_folder'])) { $this->warn(sprintf('Your assets will be uploaded to the following path: "%s"', $configurations['providers']['aws']['s3']['upload_folder'])); } else { $this->warn(sprintf('Your assets will be uploaded to the root of CDN path.')); } - if ($this->confirm('Do you wish to continue?') || $this->option('no-interaction')) { + if ($this->option('no-interaction') || $this->confirm('Do you wish to continue?')) { $this->cdn->push(); } } diff --git a/tests/CdnTest.php b/tests/CdnTest.php index b49e74f..a0f85a3 100644 --- a/tests/CdnTest.php +++ b/tests/CdnTest.php @@ -48,7 +48,7 @@ public function testPushCommandReturnTrue() $m_provider_factory->shouldReceive('create')->once()->andReturn($m_provider); $m_helper = M::mock('Publiux\laravelcdn\Contracts\CdnHelperInterface'); - $m_helper->shouldReceive('getConfigurations')->once()->andReturn([]); + $m_helper->shouldReceive('getConfigurations')->twice()->andReturn([]); $this->app->bind('Publiux\laravelcdn\Contracts\AssetInterface', function () use ($m_asset) { return $m_asset; @@ -66,9 +66,10 @@ public function testPushCommandReturnTrue() return $m_helper; }); - $result = $this->artisan('cdn:push'); - - $result->assertSuccessful(); + $this->artisan('cdn:push', ['--no-interaction' => true]) + ->expectsOutput('Your assets will be uploaded to the root of CDN path.') + ->assertExitCode(0) + ; } public function testPushCommand() @@ -101,9 +102,10 @@ public function testPushCommand() return $p_aws_s3_provider; }); - $result = $this->artisan('cdn:push'); - - $result->assertExitCode(0); + $this->artisan('cdn:push', ['--no-interaction' => true]) + ->expectsOutput('Your assets will be uploaded to the root of CDN path.') + ->assertExitCode(0) + ; } protected function getEnvironmentSetUp($app)