Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Westin Shafer authored and Westin Shafer committed Sep 21, 2017
1 parent 35c934d commit 6a6af09
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Resolver/AliasPathStackResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function resolve($name)

if ($file->isReadable() && !$file->isDir()) {
$filePath = $file->getRealPath();
$mimeType = $this->getMimeResolver()->getMimeType($filePath);
$mimeType = $this->getMimeResolver()->getMimeType($name);
$asset = new FileAsset($filePath);

$asset->mimetype = $mimeType;
Expand Down
1 change: 1 addition & 0 deletions src/Resolver/ConcatResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public function resolve($name)
$aggregateAsset = new AggregateAsset($resolvedAssets);
$this->getAssetFilterManager()->setFilters($name, $aggregateAsset);
$aggregateAsset->setTargetPath($name);
$aggregateAsset->mimetype = $this->getMimeResolver()->getMimeType($name);

return $aggregateAsset;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resolver/MapResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function resolve($name)
}

$file = $this->map[$name];
$mimeType = $this->getMimeResolver()->getMimeType($file);
$mimeType = $this->getMimeResolver()->getMimeType($name);

if (false === filter_var($file, FILTER_VALIDATE_URL)) {
$asset = new FileAsset($file);
Expand Down
2 changes: 1 addition & 1 deletion src/Resolver/PathStackResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function resolve($name)

if ($file->isReadable() && !$file->isDir()) {
$filePath = $file->getRealPath();
$mimeType = $this->getMimeResolver()->getMimeType($filePath);
$mimeType = $this->getMimeResolver()->getMimeType($name);
$asset = new FileAsset($filePath);

$asset->mimetype = $mimeType;
Expand Down
2 changes: 1 addition & 1 deletion src/Resolver/PrioritizedPathsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function resolve($name)

if ($file->isReadable() && !$file->isDir()) {
$filePath = $file->getRealPath();
$mimeType = $this->getMimeResolver()->getMimeType($filePath);
$mimeType = $this->getMimeResolver()->getMimeType($name);
$asset = new FileAsset($filePath);

$asset->mimetype = $mimeType;
Expand Down
6 changes: 3 additions & 3 deletions src/Service/MimeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class MimeResolver
'cmdf' => 'chemical/x-cmdf',
'cml' => 'chemical/x-cml',
'cod' => 'application/vnd.rim.cod',
'coffee' => 'application/javascript',
'coffee' => 'application/vnd.coffeescript',
'com' => 'application/x-msdos-program',
'cpa' => 'chemical/x-compass',
'cpio' => 'application/x-cpio',
Expand Down Expand Up @@ -238,7 +238,7 @@ class MimeResolver
'kwd' => 'application/x-kword',
'kwt' => 'application/x-kword',
'latex' => 'application/x-latex',
'less' => 'text/css',
'less' => 'text/less',
'lha' => 'application/x-lha',
'lhs' => 'text/x-literate-haskell',
'lin' => 'application/bbolin',
Expand Down Expand Up @@ -406,7 +406,7 @@ class MimeResolver
'sci' => 'application/x-scilab',
'sco' => 'audio/csound',
'scr' => 'application/x-silverlight',
'scss' => 'text/css',
'scss' => 'text/scss',
'sct' => 'text/scriptlet',
'sd' => 'chemical/x-mdl-sdfile',
'sd2' => 'audio/x-sd2',
Expand Down
2 changes: 1 addition & 1 deletion tests/Resolver/AliasPathStackResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public function testCollectDirectory()
{
$alias = 'my/alias/';
$resolver = new AliasPathStackResolver(array($alias => realpath(__DIR__ . '/../')));
$dir = substr(__DIR__, strrpos(__DIR__, '/', 0) + 1);
$dir = substr(__DIR__, strrpos(__DIR__, DIRECTORY_SEPARATOR, 0) + 1);

$this->assertContains($alias . $dir . DIRECTORY_SEPARATOR . basename(__FILE__), $resolver->collect());
$this->assertNotContains($alias . $dir . DIRECTORY_SEPARATOR . 'i-do-not-exist.php', $resolver->collect());
Expand Down
14 changes: 7 additions & 7 deletions tests/Resolver/MapResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ public function testResolveAssetSuccess()
$resolver->setMimeResolver($mimeResolver);

$asset1 = array(
'bacon' => __FILE__,
'bacon.php' => __FILE__,
);

$resolver->setMap($asset1);

$asset = $resolver->resolve('bacon');
$asset = $resolver->resolve('bacon.php');
$mimetype = $mimeResolver->getMimeType(__FILE__);

$this->assertTrue($asset instanceof Asset\FileAsset);
Expand All @@ -127,19 +127,19 @@ public function testResolveHttpAssetSuccess()
$mimeResolver = $this->createMock(MimeResolver::class);

$mimeResolver->expects($this->any())
->method('getMimeType')
->with('http://foo.bar/')
->will($this->returnValue('text/foo'));
->method('getMimeType')
->with('bacon.bar')
->will($this->returnValue('text/foo'));

$resolver->setMimeResolver($mimeResolver);

$asset1 = array(
'bacon' => 'http://foo.bar/',
'bacon.bar' => 'http://foo.bar/',
);

$resolver->setMap($asset1);

$asset = $resolver->resolve('bacon');
$asset = $resolver->resolve('bacon.bar');

$this->assertTrue($asset instanceof Asset\HttpAsset);
$this->assertSame('text/foo', $asset->mimetype);
Expand Down
2 changes: 1 addition & 1 deletion tests/Resolver/PathStackResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function testCollectDirectory()
{
$resolver = new PathStackResolver();
$resolver->addPath(realpath(__DIR__ . '/../'));
$dir = substr(__DIR__, strrpos(__DIR__, '/', 0) + 1);
$dir = substr(__DIR__, strrpos(__DIR__, DIRECTORY_SEPARATOR, 0) + 1);

$this->assertContains($dir . DIRECTORY_SEPARATOR . basename(__FILE__), $resolver->collect());
$this->assertNotContains($dir . DIRECTORY_SEPARATOR . 'i-do-not-exist.php', $resolver->collect());
Expand Down
2 changes: 1 addition & 1 deletion tests/Resolver/PrioritizedPathsResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function testCollectDirectory()
{
$resolver = new PrioritizedPathsResolver();
$resolver->addPath(realpath(__DIR__ . '/../'));
$dir = substr(__DIR__, strrpos(__DIR__, '/', 0) + 1);
$dir = substr(__DIR__, strrpos(__DIR__, DIRECTORY_SEPARATOR, 0) + 1);

$this->assertContains($dir . DIRECTORY_SEPARATOR . basename(__FILE__), $resolver->collect());
$this->assertNotContains($dir . DIRECTORY_SEPARATOR . 'i-do-not-exist.php', $resolver->collect());
Expand Down
8 changes: 4 additions & 4 deletions tests/Service/PathStackResolverServiceFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public function testCreateService()
'asset_manager' => array(
'resolver_configs' => array(
'paths' => array(
'path1/',
'path2/',
'path1' . DIRECTORY_SEPARATOR,
'path2' . DIRECTORY_SEPARATOR,
),
),
),
Expand All @@ -34,8 +34,8 @@ public function testCreateService()
$resolver = $factory($serviceManager);
$this->assertSame(
array(
'path2/',
'path1/',
'path2' . DIRECTORY_SEPARATOR,
'path1' . DIRECTORY_SEPARATOR,
),
$resolver->getPaths()->toArray()
);
Expand Down

0 comments on commit 6a6af09

Please sign in to comment.