Skip to content

Commit

Permalink
Update unit tests according to the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidgh83 committed Jun 11, 2024
1 parent df853ff commit 3458db4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
7 changes: 1 addition & 6 deletions src/Publiux/laravelcdn/Commands/PushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
16 changes: 9 additions & 7 deletions tests/CdnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3458db4

Please sign in to comment.