Skip to content

Commit

Permalink
Add test cases from feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Quetzacoalt91 committed Apr 29, 2024
1 parent 367f0b1 commit c48e92c
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions tests/unit/UpgradeContainer/FilesystemAdapterTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
Expand All @@ -23,6 +24,7 @@
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/

use PHPUnit\Framework\TestCase;
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;

Expand All @@ -48,7 +50,9 @@ public function testListFilesInDirForUpgrade()
);

$actual = $this->filesystemAdapter->listFilesInDir(
$pathToRelease, 'upgrade', true
$pathToRelease,
'upgrade',
true
);
// TODO: Should try using assertEqualsCanonicalizing after upgrade of PHPUnit
$this->assertEquals([], array_diff($expected, $actual), "There are more files in the expected array than in the actual list: \n" . implode("\n", array_diff($expected, $actual)));
Expand All @@ -65,7 +69,9 @@ public function testListFilesInDirForUpgradeWithTheme()
);

$actual = $this->filesystemAdapter->listFilesInDir(
$pathToRelease, 'upgrade', true
$pathToRelease,
'upgrade',
true
);
// TODO: Should try using assertEqualsCanonicalizing after upgrade of PHPUnit
$this->assertEquals([], array_diff($expected, $actual), "There are more files in the expected array than in the actual list: \n" . implode("\n", array_diff($expected, $actual)));
Expand All @@ -82,7 +88,9 @@ public function testFileIsIgnored($file, $fullpath, $process)
$file,
$this->container->getProperty(UpgradeContainer::PS_ROOT_PATH) . $fullpath,
$process,
$this->container->getProperty(UpgradeContainer::PS_ROOT_PATH)));
$this->container->getProperty(UpgradeContainer::PS_ROOT_PATH)
)
);
}

/**
Expand All @@ -99,7 +107,8 @@ public function testFileFromReleaseIsIgnored($file, $fullpath, $process)
$this->container->getProperty(UpgradeContainer::LATEST_PATH) . $fullpath,
$process,
$this->container->getProperty(UpgradeContainer::LATEST_PATH)
));
)
);
}

/**
Expand All @@ -112,7 +121,9 @@ public function testFileIsNotIgnored($file, $fullpath, $process)
$file,
$this->container->getProperty(UpgradeContainer::PS_ROOT_PATH) . $fullpath,
$process,
$this->container->getProperty(UpgradeContainer::PS_ROOT_PATH)));
$this->container->getProperty(UpgradeContainer::PS_ROOT_PATH)
)
);
}

public function ignoredFilesProvider()
Expand All @@ -132,6 +143,8 @@ public function ignoredFilesProvider()
['controllers', '/override/controllers', 'upgrade'],
['modules', '/override/modules', 'upgrade'],

['install', '/install', 'upgrade'],

['parameters.yml', '/app/config/parameters.yml', 'upgrade'],

['classic', '/themes/classic', 'upgrade'],
Expand All @@ -144,6 +157,10 @@ public function notIgnoredFilesProvider()
['parameters.yml', '/app/config/parameters.yml', 'backup'],
['modules', '/some/unrelated/folder/named/modules', 'upgrade'],

// The case of files is important.
['Install', '/Install', 'upgrade'],
['DframeInstaller.php', '/vendor/composer/installers/src/Composer/Installers/DframeInstaller.php', 'upgrade'],

['doge.txt', '/doge.txt', 'upgrade'],
['parameters.yml', '/parameters.yml', 'upgrade'],
['parameters.yml.dist', '/app/config/parameters.yml.dist', 'upgrade'],
Expand Down

0 comments on commit c48e92c

Please sign in to comment.