smarty-php / smarty

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.
Other
2.26k stars 712 forks source link

Fix unit tests to enable to run CacheResourceFileTest.php on Windows #1055

Closed matsuo closed 2 months ago

matsuo commented 3 months ago

This PR fixes unit tests to enable to run CacheResourceFileTest.php on Windows. (Related PR: #1046 ) Some unit tests in CacheResourceFileTest.php now take the directory separator of Windows into account.

Test Results after modification:

> php .\vendor\phpunit\phpunit\phpunit --filter=CacheResourceFileTest
PHPUnit 8.5.39 by Sebastian Bergmann and contributors.

...............................................................   63 / 63 (100%)

Time: 56.96 seconds, Memory: 18.00 MB

OK (63 tests, 258 assertions)

Current Test Results: (from https://github.com/smarty-php/smarty/pull/1046#issuecomment-2257067168 )

1) CacheResourceFileTest::testGetCachedFilepathSubDirs
Failed asserting that 'D:\a\smarty\smarty\tests\UnitTests\CacheResourceTests\File\cache\ca\25\46\ca2546820bc1a72783da84062884d71d8e3c1ff4_helloworld.tpl.php' matches PCRE pattern "/.*\/([a-f0-9]{2}\/){3}.*.php/".

D:\a\smarty\smarty\tests\UnitTests\CacheResourceTests\File\CacheResourceFileTest.php:41

2) CacheResourceFileTest::testGetCachedFilepathCacheId
Failed asserting that 'D:\a\smarty\smarty\tests\UnitTests\CacheResourceTests\File\cache\foo\bar\ca\25\46\ca2546820bc1a72783da84062884d71d8e3c1ff4_helloworld.tpl.php' matches PCRE pattern "/.*\/foo\/bar\/([a-f0-9]{2}\/){3}.*.php/".

D:\a\smarty\smarty\tests\UnitTests\CacheResourceTests\File\CacheResourceFileTest.php:54

3) CacheResourceFileTest::testGetCachedFilepathCompileId
Failed asserting that 'D:\a\smarty\smarty\tests\UnitTests\CacheResourceTests\File\cache\blar\ca\25\46\ca2546820bc1a72783da84062884d71d8e3c1ff4_helloworld.tpl.php' matches PCRE pattern "/.*\/blar\/([a-f0-9]{2}\/){3}.*.php/".

D:\a\smarty\smarty\tests\UnitTests\CacheResourceTests\File\CacheResourceFileTest.php:66

4) CacheResourceFileTest::testGetCachedFilepathCacheIdCompileId
Failed asserting that 'D:\a\smarty\smarty\tests\UnitTests\CacheResourceTests\File\cache\foo\bar\blar\ca\25\46\ca2546820bc1a72783da84062884d71d8e3c1ff4_helloworld.tpl.php' matches PCRE pattern "/.*\/foo\/bar\/blar\/([a-f0-9]{2}\/){3}.*.php/".

D:\a\smarty\smarty\tests\UnitTests\CacheResourceTests\File\CacheResourceFileTest.php:78