2016-01-28 05:35:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
use GuzzleHttp\Handler\MockHandler;
|
|
|
|
use GuzzleHttp\HandlerStack;
|
|
|
|
use GuzzleHttp\Psr7\Response;
|
|
|
|
|
|
|
|
class ApplicationTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testStaticUrlWithoutCDN()
|
|
|
|
{
|
|
|
|
putenv('CDN_URL');
|
|
|
|
|
2016-03-14 02:36:03 +00:00
|
|
|
$this->assertEquals(App::staticUrl(), 'http://localhost/');
|
|
|
|
$this->assertEquals(App::staticUrl('foo.css '), 'http://localhost/foo.css');
|
2016-01-28 05:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testStaticUrlWithCDN()
|
|
|
|
{
|
|
|
|
putenv('CDN_URL=http://cdn.bar');
|
|
|
|
|
|
|
|
$this->assertEquals(App::staticUrl(), 'http://cdn.bar/');
|
|
|
|
$this->assertEquals(App::staticUrl('foo.css '), 'http://cdn.bar/foo.css');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testRev()
|
|
|
|
{
|
|
|
|
putenv('CDN_URL');
|
|
|
|
|
2016-01-31 14:00:15 +00:00
|
|
|
$manifestFile = dirname(__FILE__).'/blobs/rev-manifest.json';
|
2016-03-14 02:36:03 +00:00
|
|
|
$this->assertEquals(App::rev('foo.css', $manifestFile), 'http://localhost/public/build/foo00.css');
|
2016-01-28 05:35:51 +00:00
|
|
|
|
|
|
|
putenv('CDN_URL=http://cdn.bar');
|
|
|
|
$this->assertEquals(App::rev('bar.js', $manifestFile), 'http://cdn.bar/public/build/bar00.js');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetLatestVersion()
|
|
|
|
{
|
|
|
|
$mock = new MockHandler([
|
2016-01-31 14:00:15 +00:00
|
|
|
new Response(200, [], file_get_contents(dirname(__FILE__).'/blobs/github-tags.json')),
|
2016-01-28 05:35:51 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
$client = new Client(['handler' => HandlerStack::create($mock)]);
|
|
|
|
|
|
|
|
$this->assertEquals('v1.1.2', App::getLatestVersion($client));
|
|
|
|
}
|
|
|
|
}
|