Skip to content

Commit

Permalink
Fix unit tests to enable to run CacheResourceFileTest.php on Windows (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
matsuo committed Aug 28, 2024
1 parent 30c6ee6 commit 2f781e2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
class CacheResourceFileTest extends CacheResourceTestCommon
{

private $directorySeparator;

public function setUp(): void
{
$this->setUpSmarty(__DIR__);
parent::setUp();
$this->directorySeparator = preg_quote(DIRECTORY_SEPARATOR, '/');
$this->smarty->setCachingType('filetest');
}

Expand All @@ -38,7 +41,8 @@ public function testGetCachedFilepathSubDirs()
$this->smarty->setUseSubDirs(true);
$tpl = $this->smarty->createTemplate('helloworld.tpl');

$this->assertRegExp('/.*\/([a-f0-9]{2}\/){3}.*.php/', $tpl->getCached()->filepath);
$pattern = '/.*' . $this->directorySeparator . '([a-f0-9]{2}' . $this->directorySeparator . '){3}.*\.php/';
$this->assertRegExp($pattern, $tpl->getCached()->filepath);
}

/**
Expand All @@ -51,7 +55,8 @@ public function testGetCachedFilepathCacheId()
$this->smarty->setUseSubDirs(true);
$tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar');

$this->assertRegExp('/.*\/foo\/bar\/([a-f0-9]{2}\/){3}.*.php/', $tpl->getCached()->filepath);
$pattern = '/.*' . $this->directorySeparator . 'foo' . $this->directorySeparator . 'bar' . $this->directorySeparator . '([a-f0-9]{2}' . $this->directorySeparator . '){3}.*\.php/';
$this->assertRegExp($pattern, $tpl->getCached()->filepath);
}

/**
Expand All @@ -63,7 +68,9 @@ public function testGetCachedFilepathCompileId()
$this->smarty->cache_lifetime = 1000;
$this->smarty->setUseSubDirs(true);
$tpl = $this->smarty->createTemplate('helloworld.tpl', null, 'blar');
$this->assertRegExp('/.*\/blar\/([a-f0-9]{2}\/){3}.*.php/', $tpl->getCached()->filepath);

$pattern = '/.*' . $this->directorySeparator . 'blar' . $this->directorySeparator . '([a-f0-9]{2}' . $this->directorySeparator . '){3}.*\.php/';
$this->assertRegExp($pattern, $tpl->getCached()->filepath);
}

/**
Expand All @@ -75,7 +82,9 @@ public function testGetCachedFilepathCacheIdCompileId()
$this->smarty->cache_lifetime = 1000;
$this->smarty->setUseSubDirs(true);
$tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar');
$this->assertRegExp('/.*\/foo\/bar\/blar\\/([a-f0-9]{2}\/){3}.*.php/', $tpl->getCached()->filepath);

$pattern = '/.*' . $this->directorySeparator . 'foo' . $this->directorySeparator . 'bar' . $this->directorySeparator . 'blar' . $this->directorySeparator . '([a-f0-9]{2}' . $this->directorySeparator . '){3}.*\.php/';
$this->assertRegExp($pattern, $tpl->getCached()->filepath);
}

/**
Expand Down

0 comments on commit 2f781e2

Please sign in to comment.