Skip to content

Commit

Permalink
Rename fixtures paths to be consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
smnandre authored and fabpot committed Oct 20, 2023
1 parent 0d73580 commit 9eb2f84
Show file tree
Hide file tree
Showing 45 changed files with 92 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vendor/
composer.lock
phpunit.xml
Tests/fixtures/var/
Tests/Fixtures/var/
2 changes: 1 addition & 1 deletion Tests/AssetMapperDevServerSubscriberFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Component\AssetMapper\Tests;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\AssetMapper\Tests\fixtures\AssetMapperTestAppKernel;
use Symfony\Component\AssetMapper\Tests\Fixtures\AssetMapperTestAppKernel;

class AssetMapperDevServerSubscriberFunctionalTest extends WebTestCase
{
Expand Down
80 changes: 40 additions & 40 deletions Tests/AssetMapperRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class AssetMapperRepositoryTest extends TestCase
public function testFindWithAbsolutePaths()
{
$repository = new AssetMapperRepository([
__DIR__.'/fixtures/dir1' => '',
__DIR__.'/fixtures/dir2' => '',
__DIR__.'/Fixtures/dir1' => '',
__DIR__.'/Fixtures/dir2' => '',
], __DIR__);

$this->assertSame(realpath(__DIR__.'/fixtures/dir1/file1.css'), $repository->find('file1.css'));
$this->assertSame(realpath(__DIR__.'/fixtures/dir2/file4.js'), $repository->find('file4.js'));
$this->assertSame(realpath(__DIR__.'/fixtures/dir2/subdir/file5.js'), $repository->find('subdir/file5.js'));
$this->assertSame(realpath(__DIR__.'/Fixtures/dir1/file1.css'), $repository->find('file1.css'));
$this->assertSame(realpath(__DIR__.'/Fixtures/dir2/file4.js'), $repository->find('file4.js'));
$this->assertSame(realpath(__DIR__.'/Fixtures/dir2/subdir/file5.js'), $repository->find('subdir/file5.js'));
$this->assertNull($repository->find('file5.css'));
}

Expand All @@ -35,34 +35,34 @@ public function testFindWithRelativePaths()
$repository = new AssetMapperRepository([
'dir1' => '',
'dir2' => '',
], __DIR__.'/fixtures');
], __DIR__.'/Fixtures');

$this->assertSame(realpath(__DIR__.'/fixtures/dir1/file1.css'), $repository->find('file1.css'));
$this->assertSame(realpath(__DIR__.'/fixtures/dir2/file4.js'), $repository->find('file4.js'));
$this->assertSame(realpath(__DIR__.'/fixtures/dir2/subdir/file5.js'), $repository->find('subdir/file5.js'));
$this->assertSame(realpath(__DIR__.'/Fixtures/dir1/file1.css'), $repository->find('file1.css'));
$this->assertSame(realpath(__DIR__.'/Fixtures/dir2/file4.js'), $repository->find('file4.js'));
$this->assertSame(realpath(__DIR__.'/Fixtures/dir2/subdir/file5.js'), $repository->find('subdir/file5.js'));
$this->assertNull($repository->find('file5.css'));
}

public function testFindWithMovingPaths()
{
$repository = new AssetMapperRepository([
__DIR__.'/../Tests/fixtures/dir2' => '',
__DIR__.'/../Tests/Fixtures/dir2' => '',
], __DIR__);

$this->assertSame(realpath(__DIR__.'/fixtures/dir2/file4.js'), $repository->find('file4.js'));
$this->assertSame(realpath(__DIR__.'/fixtures/dir2/file4.js'), $repository->find('subdir/../file4.js'));
$this->assertSame(realpath(__DIR__.'/Fixtures/dir2/file4.js'), $repository->find('file4.js'));
$this->assertSame(realpath(__DIR__.'/Fixtures/dir2/file4.js'), $repository->find('subdir/../file4.js'));
}

public function testFindWithNamespaces()
{
$repository = new AssetMapperRepository([
'dir1' => 'dir1_namespace',
'dir2' => 'dir2_namespace',
], __DIR__.'/fixtures');
], __DIR__.'/Fixtures');

$this->assertSame(realpath(__DIR__.'/fixtures/dir1/file1.css'), $repository->find('dir1_namespace/file1.css'));
$this->assertSame(realpath(__DIR__.'/fixtures/dir2/file4.js'), $repository->find('dir2_namespace/file4.js'));
$this->assertSame(realpath(__DIR__.'/fixtures/dir2/subdir/file5.js'), $repository->find('dir2_namespace/subdir/file5.js'));
$this->assertSame(realpath(__DIR__.'/Fixtures/dir1/file1.css'), $repository->find('dir1_namespace/file1.css'));
$this->assertSame(realpath(__DIR__.'/Fixtures/dir2/file4.js'), $repository->find('dir2_namespace/file4.js'));
$this->assertSame(realpath(__DIR__.'/Fixtures/dir2/subdir/file5.js'), $repository->find('dir2_namespace/subdir/file5.js'));
// non-namespaced path does not work
$this->assertNull($repository->find('file4.js'));
}
Expand All @@ -73,10 +73,10 @@ public function testFindLogicalPath()
'dir' => '',
'dir1' => 'some_namespace',
'dir2' => '',
], __DIR__.'/fixtures');
$this->assertSame('subdir/file5.js', $repository->findLogicalPath(__DIR__.'/fixtures/dir2/subdir/file5.js'));
$this->assertSame('some_namespace/file2.js', $repository->findLogicalPath(__DIR__.'/fixtures/dir1/file2.js'));
$this->assertSame('some_namespace/file2.js', $repository->findLogicalPath(__DIR__.'/../Tests/fixtures/dir1/file2.js'));
], __DIR__.'/Fixtures');
$this->assertSame('subdir/file5.js', $repository->findLogicalPath(__DIR__.'/Fixtures/dir2/subdir/file5.js'));
$this->assertSame('some_namespace/file2.js', $repository->findLogicalPath(__DIR__.'/Fixtures/dir1/file2.js'));
$this->assertSame('some_namespace/file2.js', $repository->findLogicalPath(__DIR__.'/../Tests/Fixtures/dir1/file2.js'));
}

public function testAll()
Expand All @@ -85,21 +85,21 @@ public function testAll()
'dir1' => '',
'dir2' => '',
'dir3' => '',
], __DIR__.'/fixtures');
], __DIR__.'/Fixtures');

$actualAllAssets = $repository->all();
$this->assertCount(8, $actualAllAssets);

// use realpath to normalize slashes on Windows for comparison
$expectedAllAssets = array_map('realpath', [
'file1.css' => __DIR__.'/fixtures/dir1/file1.css',
'file2.js' => __DIR__.'/fixtures/dir1/file2.js',
'already-abcdefVWXYZ0123456789.digested.css' => __DIR__.'/fixtures/dir2/already-abcdefVWXYZ0123456789.digested.css',
'file3.css' => __DIR__.'/fixtures/dir2/file3.css',
'file4.js' => __DIR__.'/fixtures/dir2/file4.js',
'subdir/file5.js' => __DIR__.'/fixtures/dir2/subdir/file5.js',
'subdir/file6.js' => __DIR__.'/fixtures/dir2/subdir/file6.js',
'test.gif.foo' => __DIR__.'/fixtures/dir3/test.gif.foo',
'file1.css' => __DIR__.'/Fixtures/dir1/file1.css',
'file2.js' => __DIR__.'/Fixtures/dir1/file2.js',
'already-abcdefVWXYZ0123456789.digested.css' => __DIR__.'/Fixtures/dir2/already-abcdefVWXYZ0123456789.digested.css',
'file3.css' => __DIR__.'/Fixtures/dir2/file3.css',
'file4.js' => __DIR__.'/Fixtures/dir2/file4.js',
'subdir/file5.js' => __DIR__.'/Fixtures/dir2/subdir/file5.js',
'subdir/file6.js' => __DIR__.'/Fixtures/dir2/subdir/file6.js',
'test.gif.foo' => __DIR__.'/Fixtures/dir3/test.gif.foo',
]);
$this->assertEquals($expectedAllAssets, array_map('realpath', $actualAllAssets));
}
Expand All @@ -110,17 +110,17 @@ public function testAllWithNamespaces()
'dir1' => 'dir1_namespace',
'dir2' => 'dir2_namespace',
'dir3' => 'dir3_namespace',
], __DIR__.'/fixtures');
], __DIR__.'/Fixtures');

$expectedAllAssets = [
'dir1_namespace/file1.css' => __DIR__.'/fixtures/dir1/file1.css',
'dir1_namespace/file2.js' => __DIR__.'/fixtures/dir1/file2.js',
'dir2_namespace/already-abcdefVWXYZ0123456789.digested.css' => __DIR__.'/fixtures/dir2/already-abcdefVWXYZ0123456789.digested.css',
'dir2_namespace/file3.css' => __DIR__.'/fixtures/dir2/file3.css',
'dir2_namespace/file4.js' => __DIR__.'/fixtures/dir2/file4.js',
'dir2_namespace/subdir/file5.js' => __DIR__.'/fixtures/dir2/subdir/file5.js',
'dir2_namespace/subdir/file6.js' => __DIR__.'/fixtures/dir2/subdir/file6.js',
'dir3_namespace/test.gif.foo' => __DIR__.'/fixtures/dir3/test.gif.foo',
'dir1_namespace/file1.css' => __DIR__.'/Fixtures/dir1/file1.css',
'dir1_namespace/file2.js' => __DIR__.'/Fixtures/dir1/file2.js',
'dir2_namespace/already-abcdefVWXYZ0123456789.digested.css' => __DIR__.'/Fixtures/dir2/already-abcdefVWXYZ0123456789.digested.css',
'dir2_namespace/file3.css' => __DIR__.'/Fixtures/dir2/file3.css',
'dir2_namespace/file4.js' => __DIR__.'/Fixtures/dir2/file4.js',
'dir2_namespace/subdir/file5.js' => __DIR__.'/Fixtures/dir2/subdir/file5.js',
'dir2_namespace/subdir/file6.js' => __DIR__.'/Fixtures/dir2/subdir/file6.js',
'dir3_namespace/test.gif.foo' => __DIR__.'/Fixtures/dir3/test.gif.foo',
];

$normalizedExpectedAllAssets = array_map('realpath', $expectedAllAssets);
Expand All @@ -146,7 +146,7 @@ public function testExcludedPaths()
'dir1' => '',
'dir2' => '',
'dir3' => '',
], __DIR__.'/fixtures', $excludedGlobs);
], __DIR__.'/Fixtures', $excludedGlobs);

$expectedAssets = [
'file1.css',
Expand All @@ -160,6 +160,6 @@ public function testExcludedPaths()
$this->assertEquals($expectedAssets, $actualAssets);

$this->assertNull($repository->find('file3.css'));
$this->assertNull($repository->findLogicalPath(__DIR__.'/fixtures/dir2/file3.css'));
$this->assertNull($repository->findLogicalPath(__DIR__.'/Fixtures/dir2/file3.css'));
}
}
10 changes: 5 additions & 5 deletions Tests/AssetMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testGetAsset()
$file1Asset = new MappedAsset('file1.css');
$this->mappedAssetFactory->expects($this->once())
->method('createMappedAsset')
->with('file1.css', realpath(__DIR__.'/fixtures/dir1/file1.css'))
->with('file1.css', realpath(__DIR__.'/Fixtures/dir1/file1.css'))
->willReturn($file1Asset);

$actualAsset = $assetMapper->getAsset('file1.css');
Expand Down Expand Up @@ -79,21 +79,21 @@ public function testGetAssetFromFilesystemPath()

$this->mappedAssetFactory->expects($this->once())
->method('createMappedAsset')
->with('file1.css', realpath(__DIR__.'/fixtures/dir1/file1.css'))
->with('file1.css', realpath(__DIR__.'/Fixtures/dir1/file1.css'))
->willReturn(new MappedAsset('file1.css'));

$asset = $assetMapper->getAssetFromSourcePath(__DIR__.'/fixtures/dir1/file1.css');
$asset = $assetMapper->getAssetFromSourcePath(__DIR__.'/Fixtures/dir1/file1.css');
$this->assertSame('file1.css', $asset->logicalPath);
}

private function createAssetMapper(): AssetMapper
{
$dirs = ['dir1' => '', 'dir2' => '', 'dir3' => ''];
$repository = new AssetMapperRepository($dirs, __DIR__.'/fixtures');
$repository = new AssetMapperRepository($dirs, __DIR__.'/Fixtures');
$pathResolver = $this->createMock(PublicAssetsPathResolverInterface::class);
$pathResolver->expects($this->any())
->method('getPublicFilesystemPath')
->willReturn(__DIR__.'/fixtures/test_public/final-assets');
->willReturn(__DIR__.'/Fixtures/test_public/final-assets');

$this->mappedAssetFactory = $this->createMock(MappedAssetFactoryInterface::class);

Expand Down
4 changes: 2 additions & 2 deletions Tests/Command/AssetMapperCompileCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\AssetMapper\Event\PreAssetsCompileEvent;
use Symfony\Component\AssetMapper\Tests\fixtures\AssetMapperTestAppKernel;
use Symfony\Component\AssetMapper\Tests\Fixtures\AssetMapperTestAppKernel;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
Expand Down Expand Up @@ -119,7 +119,7 @@ public function testEventIsDispatched()
$listenerCalled = false;
$dispatcher->addListener(PreAssetsCompileEvent::class, function (PreAssetsCompileEvent $event) use (&$listenerCalled) {
$listenerCalled = true;
$this->assertSame(realpath(__DIR__.'/../fixtures').'/public/assets', $event->getOutputDir());
$this->assertSame(realpath(__DIR__.'/../Fixtures').'/public/assets', $event->getOutputDir());
$this->assertInstanceOf(OutputInterface::class, $event->getOutput());
});

Expand Down
2 changes: 1 addition & 1 deletion Tests/Command/DebugAssetsMapperCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\AssetMapper\Tests\fixtures\AssetMapperTestAppKernel;
use Symfony\Component\AssetMapper\Tests\Fixtures\AssetMapperTestAppKernel;
use Symfony\Component\Console\Tester\CommandTester;

class DebugAssetsMapperCommandTest extends TestCase
Expand Down
20 changes: 10 additions & 10 deletions Tests/Factory/CachedMappedAssetFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class CachedMappedAssetFactoryTest extends TestCase
{
private Filesystem $filesystem;
private string $cacheDir = __DIR__.'/../fixtures/var/cache_for_mapped_asset_factory_test';
private string $cacheDir = __DIR__.'/../Fixtures/var/cache_for_mapped_asset_factory_test';

protected function setUp(): void
{
Expand All @@ -45,7 +45,7 @@ public function testCreateMappedAssetCallsInsideWhenNoCache()
true
);

$mappedAsset = new MappedAsset('file1.css', __DIR__.'/../fixtures/dir1/file1.css');
$mappedAsset = new MappedAsset('file1.css', __DIR__.'/../Fixtures/dir1/file1.css');

$factory->expects($this->once())
->method('createMappedAsset')
Expand All @@ -59,12 +59,12 @@ public function testCreateMappedAssetCallsInsideWhenNoCache()
$secondActualAsset = $cachedFactory->createMappedAsset('file1.css', '/anything/file1.css');
$this->assertNotSame($mappedAsset, $secondActualAsset);
$this->assertSame('file1.css', $secondActualAsset->logicalPath);
$this->assertSame(__DIR__.'/../fixtures/dir1/file1.css', $secondActualAsset->sourcePath);
$this->assertSame(__DIR__.'/../Fixtures/dir1/file1.css', $secondActualAsset->sourcePath);
}

public function testAssetIsNotBuiltWhenCached()
{
$sourcePath = __DIR__.'/../fixtures/dir1/file1.css';
$sourcePath = __DIR__.'/../Fixtures/dir1/file1.css';
$mappedAsset = new MappedAsset('file1.css', $sourcePath, content: 'cached content');
$this->saveConfigCache($mappedAsset);

Expand All @@ -85,19 +85,19 @@ public function testAssetIsNotBuiltWhenCached()

public function testAssetConfigCacheResourceContainsDependencies()
{
$sourcePath = realpath(__DIR__.'/../fixtures/dir1/file1.css');
$sourcePath = realpath(__DIR__.'/../Fixtures/dir1/file1.css');
$mappedAsset = new MappedAsset('file1.css', $sourcePath, content: 'cached content');

$dependentOnContentAsset = new MappedAsset('file3.css', realpath(__DIR__.'/../fixtures/dir2/file3.css'));
$dependentOnContentAsset = new MappedAsset('file3.css', realpath(__DIR__.'/../Fixtures/dir2/file3.css'));

$deeplyNestedAsset = new MappedAsset('file4.js', realpath(__DIR__.'/../fixtures/dir2/file4.js'));
$deeplyNestedAsset = new MappedAsset('file4.js', realpath(__DIR__.'/../Fixtures/dir2/file4.js'));

$dependentOnContentAsset->addDependency($deeplyNestedAsset);
$mappedAsset->addDependency($dependentOnContentAsset);

// just adding any file as an example
$mappedAsset->addFileDependency(__DIR__.'/../fixtures/importmap.php');
$mappedAsset->addFileDependency(__DIR__.'/../fixtures/dir3');
$mappedAsset->addFileDependency(__DIR__.'/../Fixtures/importmap.php');
$mappedAsset->addFileDependency(__DIR__.'/../Fixtures/dir3');

$factory = $this->createMock(MappedAssetFactoryInterface::class);
$factory->expects($this->once())
Expand All @@ -116,7 +116,7 @@ public function testAssetConfigCacheResourceContainsDependencies()
$this->assertInstanceOf(FileResource::class, $configCacheMetadata[0]);
$this->assertInstanceOf(DirectoryResource::class, $configCacheMetadata[1]);
$this->assertInstanceOf(FileResource::class, $configCacheMetadata[2]);
$this->assertSame(realpath(__DIR__.'/../fixtures/importmap.php'), $configCacheMetadata[0]->getResource());
$this->assertSame(realpath(__DIR__.'/../Fixtures/importmap.php'), $configCacheMetadata[0]->getResource());
$this->assertSame($mappedAsset->sourcePath, $configCacheMetadata[2]->getResource());
$this->assertSame($dependentOnContentAsset->sourcePath, $configCacheMetadata[3]->getResource());
$this->assertSame($deeplyNestedAsset->sourcePath, $configCacheMetadata[4]->getResource());
Expand Down
Loading

0 comments on commit 9eb2f84

Please sign in to comment.