Skip to content

Rename fixtures paths to be consistent #52169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
->notPath('#Symfony/Bridge/PhpUnit/.*Mock\.php#')
->notPath('#Symfony/Bridge/PhpUnit/.*Legacy#')
// file content autogenerated by `var_export`
->notPath('Symfony/Component/Translation/Tests/fixtures/resources.php')
->notPath('Symfony/Component/Translation/Tests/Fixtures/resources.php')
// file content autogenerated by `VarExporter::export`
->notPath('Symfony/Component/Serializer/Tests/Fixtures/serializer.class.metadata.php')
// test template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function provideMissingStrategies(): \Generator
public static function provideStrategies(string $manifestPath): \Generator
{
$httpClient = new MockHttpClient(function ($method, $url, $options) {
$filename = __DIR__.'/../fixtures/'.basename($url);
$filename = __DIR__.'/../Fixtures/'.basename($url);

if (file_exists($filename)) {
return new MockResponse(file_get_contents($filename), ['http_headers' => ['content-type' => 'application/json']]);
Expand All @@ -111,12 +111,12 @@ public static function provideStrategies(string $manifestPath): \Generator

yield [new JsonManifestVersionStrategy('https://cdn.example.com/'.$manifestPath, $httpClient)];

yield [new JsonManifestVersionStrategy(__DIR__.'/../fixtures/'.$manifestPath)];
yield [new JsonManifestVersionStrategy(__DIR__.'/../Fixtures/'.$manifestPath)];
}

public static function provideStrictStrategies(): \Generator
{
$strategy = new JsonManifestVersionStrategy(__DIR__.'/../fixtures/manifest-valid.json', null, true);
$strategy = new JsonManifestVersionStrategy(__DIR__.'/../Fixtures/manifest-valid.json', null, true);

yield [
$strategy,
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/AssetMapper/.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/
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
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 src/Symfony/Component/AssetMapper/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
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
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
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