/** * Integration Test. */ public function testPushCommand() { $configuration_file = ['bypass' => false, 'default' => 'AwsS3', 'url' => 'https://s3.amazonaws.com', 'threshold' => 10, 'providers' => ['aws' => ['s3' => ['region' => 'us-standard', 'version' => 'latest', 'buckets' => ['my-bucket-name' => '*'], 'acl' => 'public-read', 'cloudfront' => ['use' => false, 'cdn_url' => ''], 'metadata' => [], 'expires' => gmdate('D, d M Y H:i:s T', strtotime('+5 years')), 'cache-control' => 'max-age=2628000', 'version' => '']]], 'include' => ['directories' => [__DIR__], 'extensions' => [], 'patterns' => []], 'exclude' => ['directories' => [], 'files' => [], 'extensions' => [], 'patterns' => [], 'hidden' => true]]; $m_consol = M::mock('Symfony\\Component\\Console\\Output\\ConsoleOutput'); $m_consol->shouldReceive('writeln')->atLeast(1); $finder = new \Vinelab\Cdn\Finder($m_consol); $asset = new \Vinelab\Cdn\Asset(); $provider_factory = new \Vinelab\Cdn\ProviderFactory(); $m_config = M::mock('Illuminate\\Config\\Repository'); $m_config->shouldReceive('get')->with('cdn')->once()->andReturn($configuration_file); $helper = new \Vinelab\Cdn\CdnHelper($m_config); $m_console = M::mock('Symfony\\Component\\Console\\Output\\ConsoleOutput'); $m_console->shouldReceive('writeln')->atLeast(2); $m_validator = M::mock('Vinelab\\Cdn\\Validators\\Contracts\\ProviderValidatorInterface'); $m_validator->shouldReceive('validate'); $m_helper = M::mock('Vinelab\\Cdn\\CdnHelper'); $m_spl_file = M::mock('Symfony\\Component\\Finder\\SplFileInfo'); $m_spl_file->shouldReceive('getPathname')->andReturn('vinelab/cdn/tests/Vinelab/Cdn/AwsS3ProviderTest.php'); $m_spl_file->shouldReceive('getRealPath')->andReturn(__DIR__ . '/AwsS3ProviderTest.php'); // partial mock $p_aws_s3_provider = M::mock('\\Vinelab\\Cdn\\Providers\\AwsS3Provider[connect]', array($m_console, $m_validator, $m_helper)); $m_s3 = M::mock('Aws\\S3\\S3Client')->shouldIgnoreMissing(); $m_s3->shouldReceive('factory')->andReturn('Aws\\S3\\S3Client'); $m_command = M::mock('Aws\\Command'); $m_s3->shouldReceive('getCommand')->andReturn($m_command); $m_s3->shouldReceive('execute'); $p_aws_s3_provider->setS3Client($m_s3); $p_aws_s3_provider->shouldReceive('connect')->andReturn(true); \Illuminate\Support\Facades\App::shouldReceive('make')->once()->andReturn($p_aws_s3_provider); $cdn = new \Vinelab\Cdn\Cdn($finder, $asset, $provider_factory, $helper); $result = $cdn->push(); assertEquals($result, true); }
/** * Execute the console command. * * @return mixed */ public function handle() { $this->cdn->push(); }
/** * Execute the console command. * * @return mixed */ public function handle() { $this->cdn->emptyBucket(); }
/** * Execute the console command. * * @return mixed */ public function fire() { $this->cdn->emptyBucket(); }
/** * Execute the console command. * * @return mixed */ public function fire() { $this->cdn->push(); }