summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAtsushi Matsuo <famlog@gmail.com>2024-08-29 06:15:57 +0900
committerGitHub <noreply@github.com>2024-08-28 23:15:57 +0200
commit2f781e2e655f1ccbc866f51974361f04e18d3005 (patch)
treec28ef44ced0f2be173313eed5c09cbdc9fb473bb /tests
parent30c6ee64ab80154539c25ff8b8285aa5d568babf (diff)
downloadsmarty-2f781e2e655f1ccbc866f51974361f04e18d3005.tar.gz
smarty-2f781e2e655f1ccbc866f51974361f04e18d3005.tar.bz2
smarty-2f781e2e655f1ccbc866f51974361f04e18d3005.zip
Fix unit tests to enable to run CacheResourceFileTest.php on Windows (#1055)
Diffstat (limited to 'tests')
-rw-r--r--tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php b/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php
index 192cc531..9161e3d0 100644
--- a/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php
+++ b/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php
@@ -14,10 +14,13 @@ include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
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');
}
@@ -38,7 +41,8 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$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);
}
/**
@@ -51,7 +55,8 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$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);
}
/**
@@ -63,7 +68,9 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$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);
}
/**
@@ -75,7 +82,9 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$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);
}
/**