mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-04 04:24:18 +02:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 29a77ded2f | |||
| 6d06c5e61f | |||
| ba745f5b91 | |||
| 0775fa84d1 | |||
| 56ab75df2c | |||
| 383e20e6b4 | |||
| c139883770 | |||
| 6e648ed809 | |||
| 3577fc7091 | |||
| ff2ef3b0cb | |||
| aa2dcd82cf | |||
| 78d259d3b9 | |||
| 4ed569c674 | |||
| a46478d0cb | |||
| 5487e31c4b | |||
| 12ce28e265 | |||
| 139797a165 | |||
| 6709d000cd | |||
| aa6edc3c0b |
@@ -7,3 +7,5 @@ phpunit*
|
||||
.phpunit.result.cache
|
||||
vendor/*
|
||||
composer.lock
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
# AGENTS.md
|
||||
|
||||
This file is the single source of truth for AI coding assistants working in this repo (including Claude Code, claude.ai/code).
|
||||
|
||||
## Project
|
||||
|
||||
Smarty v5 — PHP template engine. Single Composer package (`smarty/smarty`), namespace `Smarty\`, source in `src/`, autoloaded via PSR-4. Supports PHP 7.2–8.5.
|
||||
|
||||
Do not use PHP syntax newer than 7.2 in `src/` unless it is guarded for older runtimes.
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
composer install
|
||||
|
||||
# Regenerate lexers and parsers (required before tests; CI runs this)
|
||||
make -B
|
||||
|
||||
# Run all tests
|
||||
php ./vendor/phpunit/phpunit/phpunit
|
||||
|
||||
# Run a single test file
|
||||
php ./vendor/phpunit/phpunit/phpunit tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php
|
||||
|
||||
# Run tests matching a PHPUnit group
|
||||
php ./vendor/phpunit/phpunit/phpunit --group 20221124
|
||||
|
||||
# Run tests excluding slow group
|
||||
php ./vendor/phpunit/phpunit/phpunit --exclude-group slow
|
||||
```
|
||||
|
||||
There is no linter or static analysis configured. No typecheck step.
|
||||
|
||||
## Generated code — do not hand-edit
|
||||
|
||||
Four files are generated from grammar/lexer definitions via `make`:
|
||||
|
||||
| Source (edit this) | Generated (do not edit) |
|
||||
|---|---|
|
||||
| `src/Lexer/TemplateLexer.plex` | `src/Lexer/TemplateLexer.php` |
|
||||
| `src/Lexer/ConfigfileLexer.plex` | `src/Lexer/ConfigfileLexer.php` |
|
||||
| `src/Parser/TemplateParser.y` | `src/Parser/TemplateParser.php` |
|
||||
| `src/Parser/ConfigfileParser.y` | `src/Parser/ConfigfileParser.php` |
|
||||
|
||||
After editing a `.plex` or `.y` file, run `make -B` to regenerate. The generators require the `smarty/smarty-lexer` dev dependency.
|
||||
|
||||
## Architecture
|
||||
|
||||
- `src/Smarty.php` — main class, extends `TemplateBase`. Version constant: `Smarty::SMARTY_VERSION`.
|
||||
- `src/Compile/`, `src/Compiler/` — template compilation pipeline.
|
||||
- `src/Lexer/`, `src/Parser/` — lexer/parser (generated, see above).
|
||||
- `src/Extension/` — extension system (`ExtensionInterface`, `CoreExtension`, `DefaultExtension`, `BCPluginsAdapter`).
|
||||
- `src/Runtime/` — runtime helpers (foreach, capture, inheritance, tpl functions).
|
||||
- `src/Resource/`, `src/Cacheresource/` — template resource and cache resource handlers.
|
||||
- `src/BlockHandler/`, `src/FunctionHandler/`, `src/Filter/` — built-in tags, functions, and filters.
|
||||
- `libs/Smarty.class.php` — non-Composer autoload stub. Points to `src/`. Not the main source.
|
||||
- `src/functions.php` — global helper functions, always loaded via Composer `files` autoload.
|
||||
|
||||
## Tests
|
||||
|
||||
- Framework: PHPUnit 7.5/8.5 (bootstrap: `tests/Bootstrap.php`).
|
||||
- All tests extend `PHPUnit_Smarty` (defined in `tests/PHPUnit_Smarty.php`), which provides `setUpSmarty($dir)`.
|
||||
- Test suite root: `tests/UnitTests/`. Typical test `setUp()` calls `$this->setUpSmarty(__DIR__)`.
|
||||
- Each test directory may have its own `templates/`, `configs/` subdirectories. Compiled output goes to `templates_c/` and `cache/` (auto-created by the test harness).
|
||||
- Running the suite scatters generated `templates_c/`, `cache/`, and `templates_tmp/` directories (and empty runtime `templates/`/`configs/` dirs) throughout `tests/` and the repo root. These are not tracked — treat them as noise in `git status`, never commit them, and clean them with `git clean -fd` (exclude tool dirs like `.serena`).
|
||||
- Three test files are excluded in `phpunit.xml`: Memcache, APC, and HttpModifiedSince tests (require external services).
|
||||
- Tests needing MySQL/PDO are gated by constants in `tests/Config.php` (disabled by default).
|
||||
|
||||
## CI
|
||||
|
||||
GitHub Actions (`.github/workflows/ci.yml`): matrix of PHP 7.2–8.5 on ubuntu + windows. Steps: `composer install` → `make -B` → `phpunit`. No deploy step.
|
||||
|
||||
## Docs
|
||||
|
||||
Markdown in `docs/`, built with mkdocs + Material theme. Preview: `mkdocs serve`. Published via `mike deploy 5.x`.
|
||||
|
||||
## Release
|
||||
|
||||
`./make-release.sh <version>` — only v5.x.x. Updates changelog and version constant, creates a merge commit and tag on `master`.
|
||||
@@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [5.8.1] - 2026-06-23
|
||||
- Re-activated unit tests for user literals, which were previously disabled due to a bug in refactoring to v5.
|
||||
- fixed a bug where child template's block content leaked into subsequent rendering of the parent template [#1189](https://github.com/smarty-php/smarty/issues/1189)
|
||||
- Moved all unit test-generated output from inside the working tree to tmp files [#1178](https://github.com/smarty-php/smarty/issues/1178)
|
||||
|
||||
|
||||
## [5.8.0] - 2026-02-15
|
||||
- Added support for Backed Enums for php versions >= 8.1 [#1171](https://github.com/smarty-php/smarty/pull/1171)
|
||||
- Added support for new 'matches' operator doing regex matching [#1169](https://github.com/smarty-php/smarty/pull/1169)
|
||||
- Update documentation to clarify that include inline is currently not implemented in Smarty v5 [#1152](https://github.com/smarty-php/smarty/issues/1152)
|
||||
- Support for Laravel Collections style object chaining for objects return from function calls implemented as modifiers [#1151](https://github.com/smarty-php/smarty/issues/1151)
|
||||
|
||||
|
||||
## [5.7.0] - 2025-11-19
|
||||
- PHP 8.5 support
|
||||
|
||||
|
||||
@@ -115,5 +115,7 @@ If you are a maintainer, you can publish the document using [mike](https://githu
|
||||
mike deploy 5.x
|
||||
```
|
||||
|
||||
Then, push the `gh-pages` branch.
|
||||
|
||||
## Attribution
|
||||
This guide is based on the **contributing.md**. [Make your own](https://contributing.md/)!
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
## include inline
|
||||
- Re-introduce merge_compiled_includes and the {include inline} attribute?
|
||||
|
||||
## Output buffering
|
||||
- Fix ob_ output buffering commands being scattered around the codebase
|
||||
## Output buffering (major)
|
||||
- Fix ob_ output buffering commands being scattered around the codebase: Smarty's output model is fundamentally "echo everything, wrap in a buffer to capture". An alternative that would be where rendering returns a string rather than echoing — but that touches the entire compiled template format (the unifunc functions all echo) and is a large change.
|
||||
|
||||
## Review public static vars
|
||||
## Review public static vars (major)
|
||||
- such as _CHARSET and _IS_WINDOWS
|
||||
|
||||
## Block / inheritance
|
||||
@@ -24,9 +24,8 @@
|
||||
## Plugin system
|
||||
- fix template security checks in one place in compiler
|
||||
|
||||
## Beatify output
|
||||
## Beatify output (major)
|
||||
- compiled templates could be proper classes, possibly using [nette/php-generator](https://packagist.org/packages/nette/php-generator)
|
||||
|
||||
## Unrelated / other
|
||||
- review (and avoid) use of 'clone' keyword
|
||||
- what is 'user literal support', why are unit tests skipped?
|
||||
|
||||
@@ -50,6 +50,120 @@ separated from surrounding elements by spaces. Note that items listed in
|
||||
| is \[not\] odd by | | $a is not odd by $b | \[not\] an odd grouping | ($a / $b) % 2 != 0 |
|
||||
| is in | | $a is in $b | exists in array | in_array($a, $b) |
|
||||
| is \[not\] in | | $a is not in $b | does not exist in array | !in_array($a, $b) |
|
||||
| matches | | $a matches $b | regex pattern match | preg_match($b, $a) |
|
||||
|
||||
## Regex Matching Operator
|
||||
|
||||
The `matches` operator allows you to test if a string matches a regular expression pattern.
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```smarty
|
||||
{if "hello" matches "/^[a-z]+$/"}
|
||||
String matches the pattern!
|
||||
{/if}
|
||||
|
||||
{if $email matches "/^[^@]+@[^@]+\.[^@]+$/"}
|
||||
Valid email format
|
||||
{else}
|
||||
Invalid email format
|
||||
{/if}
|
||||
```
|
||||
|
||||
### Using Variables
|
||||
|
||||
```smarty
|
||||
{$pattern = '/^[a-zA-Z0-9]{8,}$/'}
|
||||
{if $password matches $pattern}
|
||||
Password meets requirements
|
||||
{else}
|
||||
Password must be at least 8 alphanumeric characters
|
||||
{/if}
|
||||
```
|
||||
|
||||
### Pattern Modifiers
|
||||
|
||||
The `matches` operator supports all standard PHP regex modifiers:
|
||||
|
||||
```smarty
|
||||
{* Case insensitive matching *}
|
||||
{if "HELLO" matches "/hello/i"}
|
||||
Matches (case insensitive)
|
||||
{/if}
|
||||
|
||||
{* Multiline mode *}
|
||||
{if "line1\nline2" matches "/line2$/m"}
|
||||
Matches in multiline mode
|
||||
{/if}
|
||||
|
||||
{* Dot matches newlines *}
|
||||
{if "hello\nworld" matches "/hello.world/s"}
|
||||
Matches with dotall modifier
|
||||
{/if}
|
||||
```
|
||||
|
||||
### Complex Conditions
|
||||
|
||||
The `matches` operator can be combined with other operators:
|
||||
|
||||
```smarty
|
||||
{if $username matches "/^[a-z]+$/" && $username|length > 3}
|
||||
Valid username
|
||||
{else}
|
||||
Username must be lowercase letters and at least 4 characters
|
||||
{/if}
|
||||
|
||||
{if $input matches "/^[0-9]+$/" || $input matches "/^[a-z]+$/"}
|
||||
Input is either numeric or lowercase letters
|
||||
{else}
|
||||
Invalid input format
|
||||
{/if}
|
||||
```
|
||||
|
||||
### Practical Examples
|
||||
|
||||
**Email Validation:**
|
||||
```smarty
|
||||
{if $email matches "/^[^@\s]+@[^@\s]+\.[^@\s]+$/"}
|
||||
Valid email address
|
||||
{else}
|
||||
Please enter a valid email address
|
||||
{/if}
|
||||
```
|
||||
|
||||
**Password Strength:**
|
||||
```smarty
|
||||
{if $password matches "/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$/"}
|
||||
Strong password
|
||||
{else}
|
||||
Password must contain uppercase, lowercase, numbers and be at least 8 characters
|
||||
{/if}
|
||||
```
|
||||
|
||||
**URL Validation:**
|
||||
```smarty
|
||||
{if $url matches "/^https?:\/\/(www\.)?[a-z0-9\-]+(\.[a-z]{2,})+/i"}
|
||||
Valid URL format
|
||||
{else}
|
||||
Please enter a valid URL
|
||||
{/if}
|
||||
```
|
||||
|
||||
**Numeric Validation:**
|
||||
```smarty
|
||||
{if $input matches "/^[0-9]+$/"}
|
||||
Valid numeric input
|
||||
{else}
|
||||
Please enter numbers only
|
||||
{/if}
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
- The `matches` operator uses PHP's `preg_match()` function internally
|
||||
- Pattern delimiters must be valid regex delimiters (typically `/`)
|
||||
- Invalid patterns will cause PHP warnings but won't break template execution
|
||||
- For complex regex patterns, consider using variables for better readability
|
||||
|
||||
## Ternary
|
||||
You can use the `?:` (or ternary) operator to test one expression and present the value
|
||||
|
||||
@@ -47,11 +47,13 @@ available within the included template.
|
||||
|
||||
## Option Flags
|
||||
|
||||
| Name | Description |
|
||||
|---------|--------------------------------------------------------------------------------------|
|
||||
| nocache | Disables caching of this subtemplate |
|
||||
| caching | Enable caching of this subtemplate |
|
||||
| inline | If set, merge the compile-code of the subtemplate into the compiled calling template |
|
||||
| Name | Description |
|
||||
|-----------|--------------------------------------------------------------------------------------|
|
||||
| nocache | Disables caching of this subtemplate |
|
||||
| caching | Enable caching of this subtemplate |
|
||||
| inline \* | If set, merge the compile-code of the subtemplate into the compiled calling template |
|
||||
|
||||
\* The `inline` option flag is currently not implemented in Smarty v5. Using it will not trigger an error, however.
|
||||
|
||||
## Examples
|
||||
```smarty
|
||||
|
||||
@@ -123,4 +123,89 @@ this will output:
|
||||
```html
|
||||
name: Zaphod Beeblebrox<br />
|
||||
email: zaphod@slartibartfast.example.com<br />
|
||||
```
|
||||
```
|
||||
|
||||
## Backed Enums (PHP 8.1+)
|
||||
|
||||
Smarty supports accessing properties of [backed enums](https://www.php.net/manual/en/language.enumerations.backed.php) introduced in PHP 8.1.
|
||||
|
||||
### Accessing Enum Properties
|
||||
|
||||
You can access the `name` and `value` properties of backed enum cases:
|
||||
|
||||
```smarty
|
||||
{* Access enum case properties *}
|
||||
<option id="{MyEnum::Foo->name}">{MyEnum::Foo->value}</option>
|
||||
```
|
||||
|
||||
### Complete Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Smarty\Smarty;
|
||||
|
||||
// Define a backed enum
|
||||
enum Status: string {
|
||||
case Active = 'active';
|
||||
case Inactive = 'inactive';
|
||||
case Pending = 'pending';
|
||||
}
|
||||
|
||||
$smarty = new Smarty();
|
||||
$smarty->assign('currentStatus', Status::Active);
|
||||
$smarty->display('template.tpl');
|
||||
```
|
||||
|
||||
`template.tpl`:
|
||||
|
||||
```smarty
|
||||
{* Display enum properties *}
|
||||
Current status: {$currentStatus->name} (value: {$currentStatus->value})
|
||||
|
||||
{* Use in HTML attributes *}
|
||||
<select name="status">
|
||||
<option value="{Status::Active->value}" {if $currentStatus->name === 'Active'}selected{/if}>Active</option>
|
||||
<option value="{Status::Inactive->value}" {if $currentStatus->name === 'Inactive'}selected{/if}>Inactive</option>
|
||||
<option value="{Status::Pending->value}" {if $currentStatus->name === 'Pending'}selected{/if}>Pending</option>
|
||||
</select>
|
||||
```
|
||||
|
||||
This would output:
|
||||
|
||||
```html
|
||||
Current status: Active (value: active)
|
||||
|
||||
<select name="status">
|
||||
<option value="active" selected>Active</option>
|
||||
<option value="inactive">Inactive</option>
|
||||
<option value="pending">Pending</option>
|
||||
</select>
|
||||
```
|
||||
|
||||
### Integer-backed Enums
|
||||
|
||||
Integer-backed enums work the same way:
|
||||
|
||||
```php
|
||||
<?php
|
||||
enum Priority: int {
|
||||
case Low = 1;
|
||||
case Medium = 2;
|
||||
case High = 3;
|
||||
}
|
||||
|
||||
$smarty->assign('priority', Priority::High);
|
||||
```
|
||||
|
||||
```smarty
|
||||
{* Access integer enum properties *}
|
||||
Priority level: {$priority->value} ({$priority->name})
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```html
|
||||
Priority level: 3 (High)
|
||||
```
|
||||
|
||||
> **Note**: Backed enum support requires PHP 8.1 or higher. The enum must be registered or available in the current namespace.
|
||||
@@ -22,6 +22,8 @@ Some of Smarty's features:
|
||||
- [Template Inheritance](api/inheritance.md) for
|
||||
easy management of template content.
|
||||
- [Plugin](api/extending/introduction.md) architecture
|
||||
- Regex pattern matching with the [`matches`](designers/language-basic-syntax/language-syntax-operators.md#regex-matching-operator) operator
|
||||
- Support for PHP 8.1+ [backed enums](designers/language-variables/language-assigned-variables.md#backed-enums-php-81)
|
||||
|
||||
## Separation of presentation from application code
|
||||
- This means templates can certainly contain logic under the condition
|
||||
|
||||
@@ -8,6 +8,25 @@ It allows you to write **templates**, using **variables**, **modifiers**, **func
|
||||
<p>
|
||||
The number of pixels is: {math equation="x * y" x=$height y=$width}.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{if $email matches "/^[^@]+@[^@]+\.[^@]+$/"}
|
||||
Valid email address
|
||||
{else}
|
||||
Please enter a valid email
|
||||
{/if}
|
||||
</p>
|
||||
```
|
||||
```html
|
||||
<h1>Hello world</h1>
|
||||
|
||||
<p>
|
||||
The number of pixels is: 307200.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Valid email address
|
||||
</p>
|
||||
```
|
||||
|
||||
When this template is rendered, with the value "Hello world" for the variable $title, 640 for $width,
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
<testsuite name="foo">
|
||||
<directory>./tests/UnitTests/</directory>
|
||||
<exclude>./tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php</exclude>
|
||||
<exclude>./tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php</exclude>
|
||||
<exclude>./tests/UnitTests/CacheModify/ModifiedSince/HttpModifiedSinceTest.php</exclude>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
@@ -127,8 +127,6 @@ class File extends Base
|
||||
&& (!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api'))) < 1
|
||||
) {
|
||||
opcache_invalidate($_template->getCached()->filepath, true);
|
||||
} elseif (function_exists('apc_compile_file')) {
|
||||
apc_compile_file($_template->getCached()->filepath);
|
||||
}
|
||||
$cached = $_template->getCached();
|
||||
$cached->timestamp = $cached->exists = is_file($cached->filepath);
|
||||
@@ -145,7 +143,7 @@ class File extends Base
|
||||
*
|
||||
* @param Template $_template template object
|
||||
*
|
||||
* @return string content
|
||||
* @return string|false content
|
||||
*/
|
||||
public function retrieveCachedContent(Template $_template)
|
||||
{
|
||||
@@ -223,10 +221,8 @@ class File extends Base
|
||||
$_filepath = (string)$_file;
|
||||
// directory ?
|
||||
if ($_file->isDir()) {
|
||||
if (!$_cache->isDot()) {
|
||||
// delete folder if empty
|
||||
@rmdir($_file->getPathname());
|
||||
}
|
||||
// delete folder if empty
|
||||
@rmdir($_file->getPathname());
|
||||
} else {
|
||||
// delete only php files
|
||||
if (substr($_filepath, -4) !== '.php') {
|
||||
@@ -279,8 +275,6 @@ class File extends Base
|
||||
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)
|
||||
) {
|
||||
opcache_invalidate($_filepath, true);
|
||||
} elseif (function_exists('apc_delete_file')) {
|
||||
apc_delete_file($_filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+44
-38
@@ -160,6 +160,7 @@ class TemplateLexer
|
||||
'LOGOP' => '"<", "==" ... logical operator',
|
||||
'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
|
||||
'SCOND' => '"is even" ... if condition',
|
||||
'MATCHES' => '"matches" regex operator',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -567,7 +568,7 @@ class TemplateLexer
|
||||
public function yylex3()
|
||||
{
|
||||
if (!isset($this->yy_global_pattern3)) {
|
||||
$this->yy_global_pattern3 = $this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+(not\\s+)?in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G(array\\s*[(]\\s*)|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS");
|
||||
$this->yy_global_pattern3 = $this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+(not\\s+)?in\\s+)|\G(\\s+matches\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G(array\\s*[(]\\s*)|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS");
|
||||
}
|
||||
if (!isset($this->dataLength)) {
|
||||
$this->dataLength = strlen($this->data);
|
||||
@@ -662,119 +663,124 @@ class TemplateLexer
|
||||
public function yy_r3_10()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_AS;
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_MATCHES;
|
||||
}
|
||||
public function yy_r3_11()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_TO;
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_AS;
|
||||
}
|
||||
public function yy_r3_12()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_STEP;
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_TO;
|
||||
}
|
||||
public function yy_r3_13()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_INSTANCEOF;
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_STEP;
|
||||
}
|
||||
public function yy_r3_14()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_INSTANCEOF;
|
||||
}
|
||||
public function yy_r3_15()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_LOGOP;
|
||||
}
|
||||
public function yy_r3_16()
|
||||
public function yy_r3_17()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_SLOGOP;
|
||||
}
|
||||
public function yy_r3_18()
|
||||
public function yy_r3_19()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_TLOGOP;
|
||||
}
|
||||
public function yy_r3_21()
|
||||
public function yy_r3_22()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_SINGLECOND;
|
||||
}
|
||||
public function yy_r3_24()
|
||||
public function yy_r3_25()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_NOT;
|
||||
}
|
||||
public function yy_r3_25()
|
||||
public function yy_r3_26()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_TYPECAST;
|
||||
}
|
||||
public function yy_r3_29()
|
||||
public function yy_r3_30()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_OPENP;
|
||||
}
|
||||
public function yy_r3_30()
|
||||
public function yy_r3_31()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_CLOSEP;
|
||||
}
|
||||
public function yy_r3_31()
|
||||
public function yy_r3_32()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_OPENB;
|
||||
}
|
||||
public function yy_r3_32()
|
||||
public function yy_r3_33()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_CLOSEB;
|
||||
}
|
||||
public function yy_r3_33()
|
||||
public function yy_r3_34()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_PTR;
|
||||
}
|
||||
public function yy_r3_34()
|
||||
public function yy_r3_35()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_APTR;
|
||||
}
|
||||
public function yy_r3_35()
|
||||
public function yy_r3_36()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_EQUAL;
|
||||
}
|
||||
public function yy_r3_36()
|
||||
public function yy_r3_37()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_INCDEC;
|
||||
}
|
||||
public function yy_r3_38()
|
||||
public function yy_r3_39()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_UNIMATH;
|
||||
}
|
||||
public function yy_r3_40()
|
||||
public function yy_r3_41()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_MATH;
|
||||
}
|
||||
public function yy_r3_42()
|
||||
public function yy_r3_43()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_AT;
|
||||
}
|
||||
public function yy_r3_43()
|
||||
public function yy_r3_44()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_ARRAYOPEN;
|
||||
}
|
||||
public function yy_r3_44()
|
||||
public function yy_r3_45()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_HATCH;
|
||||
}
|
||||
public function yy_r3_45()
|
||||
public function yy_r3_46()
|
||||
{
|
||||
|
||||
// resolve conflicts with shorttag and right_delimiter starting with '='
|
||||
@@ -786,73 +792,73 @@ class TemplateLexer
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_ATTR;
|
||||
}
|
||||
}
|
||||
public function yy_r3_46()
|
||||
public function yy_r3_47()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_NAMESPACE;
|
||||
}
|
||||
public function yy_r3_49()
|
||||
public function yy_r3_50()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_ID;
|
||||
}
|
||||
public function yy_r3_50()
|
||||
public function yy_r3_51()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_INTEGER;
|
||||
}
|
||||
public function yy_r3_51()
|
||||
public function yy_r3_52()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_BACKTICK;
|
||||
$this->yypopstate();
|
||||
}
|
||||
public function yy_r3_52()
|
||||
public function yy_r3_53()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_VERT;
|
||||
}
|
||||
public function yy_r3_53()
|
||||
public function yy_r3_54()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_DOT;
|
||||
}
|
||||
public function yy_r3_54()
|
||||
public function yy_r3_55()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_COMMA;
|
||||
}
|
||||
public function yy_r3_55()
|
||||
public function yy_r3_56()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_SEMICOLON;
|
||||
}
|
||||
public function yy_r3_56()
|
||||
public function yy_r3_57()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_DOUBLECOLON;
|
||||
}
|
||||
public function yy_r3_57()
|
||||
public function yy_r3_58()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_COLON;
|
||||
}
|
||||
public function yy_r3_58()
|
||||
public function yy_r3_59()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_QMARK;
|
||||
}
|
||||
public function yy_r3_59()
|
||||
public function yy_r3_60()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_HEX;
|
||||
}
|
||||
public function yy_r3_60()
|
||||
public function yy_r3_61()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_SPACE;
|
||||
}
|
||||
public function yy_r3_61()
|
||||
public function yy_r3_62()
|
||||
{
|
||||
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_TEXT;
|
||||
|
||||
@@ -160,6 +160,7 @@ class TemplateLexer
|
||||
'LOGOP' => '"<", "==" ... logical operator',
|
||||
'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
|
||||
'SCOND' => '"is even" ... if condition',
|
||||
'MATCHES' => '"matches" regex operator',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -325,6 +326,7 @@ class TemplateLexer
|
||||
tlop = ~\s+is\s+(not\s+)?(odd|even|div)\s+by\s+~
|
||||
scond = ~\s+is\s+(not\s+)?(odd|even)~
|
||||
isin = ~\s+is\s+(not\s+)?in\s+~
|
||||
matches = ~\s+matches\s+~
|
||||
as = ~\s+as\s+~
|
||||
to = ~\s+to\s+~
|
||||
step = ~\s+step\s+~
|
||||
@@ -469,6 +471,9 @@ class TemplateLexer
|
||||
isin {
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_ISIN;
|
||||
}
|
||||
matches {
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_MATCHES;
|
||||
}
|
||||
as {
|
||||
$this->token = \Smarty\Parser\TemplateParser::TP_AS;
|
||||
}
|
||||
|
||||
+1206
-1136
File diff suppressed because it is too large
Load Diff
@@ -681,6 +681,11 @@ expr(res) ::= expr(e1) isin(c) value(v). {
|
||||
res = c . e1.',(array)'.v.')';
|
||||
}
|
||||
|
||||
// regex matching
|
||||
expr(res) ::= expr(e1) matchop(c) value(e2). {
|
||||
res = c . e2 . ',' . e1 . ') ';
|
||||
}
|
||||
|
||||
// null coalescing
|
||||
nullcoalescing(res) ::= expr(v) QMARK QMARK expr(e2). {
|
||||
res = v.' ?? '.e2;
|
||||
@@ -1062,12 +1067,22 @@ object(res) ::= varindexed(vi) objectchain(oc). {
|
||||
}
|
||||
}
|
||||
|
||||
// optional objectchain - empty
|
||||
optobjectchain(res) ::= . {
|
||||
res = '';
|
||||
}
|
||||
|
||||
// optional objectchain - present
|
||||
optobjectchain(res) ::= objectchain(oc). {
|
||||
res = oc;
|
||||
}
|
||||
|
||||
// single element
|
||||
objectchain(res) ::= objectelement(oe). {
|
||||
res = oe;
|
||||
}
|
||||
|
||||
// chain of elements
|
||||
// chain of elements
|
||||
objectchain(res) ::= objectchain(oc) objectelement(oe). {
|
||||
res = oc.oe;
|
||||
}
|
||||
@@ -1111,7 +1126,7 @@ objectelement(res)::= PTR method(f). {
|
||||
//
|
||||
// function
|
||||
//
|
||||
function(res) ::= ns1(f) OPENP variablelist(v) CLOSEP. {
|
||||
function(res) ::= ns1(f) OPENP variablelist(v) CLOSEP optobjectchain(oc). {
|
||||
|
||||
if (f == 'isset') {
|
||||
res = '(true';
|
||||
@@ -1125,15 +1140,15 @@ function(res) ::= ns1(f) OPENP variablelist(v) CLOSEP. {
|
||||
res .= ' && (' . $value . ' !== null)';
|
||||
}
|
||||
}
|
||||
res .= ')';
|
||||
res .= ')' . oc;
|
||||
} elseif (f == 'empty') {
|
||||
if (count(v) != 1) {
|
||||
throw new CompilerException("Invalid number of arguments for empty. empty expects at exactly one parameter.");
|
||||
}
|
||||
if (is_array(v[0])) {
|
||||
res .= '( !' . v[0][0] . ' || empty(' . v[0][1] . '))';
|
||||
res = '( !' . v[0][0] . ' || empty(' . v[0][1] . '))' . oc;
|
||||
} else {
|
||||
res = 'false == ' . v[0];
|
||||
res = 'false == ' . v[0] . oc;
|
||||
}
|
||||
} else {
|
||||
$p = array();
|
||||
@@ -1144,7 +1159,7 @@ function(res) ::= ns1(f) OPENP variablelist(v) CLOSEP. {
|
||||
$p[] = $value;
|
||||
}
|
||||
}
|
||||
res = $this->compiler->compileModifierInExpression(f, $p);
|
||||
res = $this->compiler->compileModifierInExpression(f, $p) . oc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1244,6 +1259,11 @@ static_class_access(res) ::= ID(v). {
|
||||
res = array(v, '');
|
||||
}
|
||||
|
||||
// static class constant with object chain
|
||||
static_class_access(res) ::= ID(v) objectchain(oc). {
|
||||
res = array(v, oc);
|
||||
}
|
||||
|
||||
// static class variables
|
||||
static_class_access(res) ::= DOLLARID(v) arrayindex(a). {
|
||||
res = array(v, a, 'property');
|
||||
@@ -1303,6 +1323,10 @@ scond(res) ::= SINGLECOND(o). {
|
||||
res = $scond[$op];
|
||||
}
|
||||
|
||||
matchop(res) ::= MATCHES(o). {
|
||||
res = 'preg_match(';
|
||||
}
|
||||
|
||||
//
|
||||
// ARRAY element assignment
|
||||
//
|
||||
|
||||
@@ -69,8 +69,12 @@ class InheritanceRuntime {
|
||||
* @param array $blockNames outer level block name
|
||||
*/
|
||||
public function init(Template $tpl, $initChild, $blockNames = []) {
|
||||
// if called while executing parent template it must be a sub-template with new inheritance root
|
||||
if ($initChild && $this->state === 3 && (strpos($tpl->template_resource, 'extendsall') === false)) {
|
||||
// if called while executing parent template it must be a sub-template with new inheritance root.
|
||||
// A new root is started either by a child template ($initChild) or by a sub-template included
|
||||
// outside of any block rendering (empty source stack); the latter must not inherit the leftover
|
||||
// block overrides of a previously completed inheritance tree (see issue #1189).
|
||||
if (($initChild || empty($this->sourceStack)) && $this->state === 3
|
||||
&& (strpos($tpl->template_resource, 'extendsall') === false)) {
|
||||
$tpl->setInheritance(clone $tpl->getSmarty()->getRuntime('Inheritance'));
|
||||
$tpl->getInheritance()->init($tpl, $initChild, $blockNames);
|
||||
return;
|
||||
|
||||
+3
-7
@@ -54,7 +54,7 @@ class Smarty extends \Smarty\TemplateBase {
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '5.7.0';
|
||||
const SMARTY_VERSION = '5.8.1';
|
||||
|
||||
/**
|
||||
* define caching modes
|
||||
@@ -1344,10 +1344,8 @@ class Smarty extends \Smarty\TemplateBase {
|
||||
}
|
||||
$_filepath = (string)$_file;
|
||||
if ($_file->isDir()) {
|
||||
if (!$_compile->isDot()) {
|
||||
// delete folder if empty
|
||||
@rmdir($_file->getPathname());
|
||||
}
|
||||
// delete folder if empty
|
||||
@rmdir($_file->getPathname());
|
||||
} else {
|
||||
// delete only php files
|
||||
if (substr($_filepath, -4) !== '.php') {
|
||||
@@ -1385,8 +1383,6 @@ class Smarty extends \Smarty\TemplateBase {
|
||||
&& (!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api')) < 1)
|
||||
) {
|
||||
opcache_invalidate($_filepath, true);
|
||||
} elseif (function_exists('apc_delete_file')) {
|
||||
apc_delete_file($_filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,8 +251,6 @@ class Compiled extends GeneratedPhpFile {
|
||||
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)
|
||||
) {
|
||||
opcache_invalidate($this->filepath, true);
|
||||
} elseif (function_exists('apc_compile_file')) {
|
||||
apc_compile_file($this->filepath);
|
||||
}
|
||||
}
|
||||
if (defined('HHVM_VERSION')) {
|
||||
|
||||
@@ -15,4 +15,3 @@ if (!ini_get('date.timezone')) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
/*
|
||||
* Smarty PHPUnit Config
|
||||
*/
|
||||
define('individualFolders', true);
|
||||
define('MysqlCacheEnable', false);
|
||||
define('PdoCacheEnable', false);
|
||||
define('PdoGzipCacheEnable', false);
|
||||
|
||||
+129
-47
@@ -49,6 +49,37 @@ class PHPUnit_Smarty extends PHPUnit\Framework\TestCase
|
||||
*/
|
||||
public static $cwd = null;
|
||||
|
||||
/**
|
||||
* Temp directory base for this test class (compile, cache, templates_tmp)
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
private static $tempBase = null;
|
||||
|
||||
/**
|
||||
* Unique token for the current test class's temp directory.
|
||||
* Generated once per class.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
private static $tempId = null;
|
||||
|
||||
/**
|
||||
* Return the temp directory base for the current test class.
|
||||
*
|
||||
* @return string
|
||||
* @throws \LogicException If the temp directory base has not been initialized yet.
|
||||
*/
|
||||
public static function getTempBase(): string
|
||||
{
|
||||
if (self::$tempBase === null) {
|
||||
throw new \LogicException(
|
||||
'Temp directory base has not been initialized. Call setUpSmarty() before using temp-path helpers.'
|
||||
);
|
||||
}
|
||||
return self::$tempBase;
|
||||
}
|
||||
|
||||
/**
|
||||
* PDO object for Mysql tests
|
||||
*
|
||||
@@ -75,8 +106,37 @@ class PHPUnit_Smarty extends PHPUnit\Framework\TestCase
|
||||
*/
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
//self::$pdo = null;
|
||||
self::$testNumber = 0;
|
||||
// Remove the unique temp directory for this test class unless the caller
|
||||
// wants to inspect the artifacts (e.g. for debugging a failure).
|
||||
if (!getenv('KEEP_SMARTY_TEST_ARTIFACTS') && self::$tempBase !== null && is_dir(self::$tempBase)) {
|
||||
self::removeDir(self::$tempBase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively remove a directory, silently ignoring any errors.
|
||||
*
|
||||
* @param string $dir
|
||||
*/
|
||||
private static function removeDir(string $dir): void
|
||||
{
|
||||
$dir = rtrim($dir, DIRECTORY_SEPARATOR);
|
||||
$items = @scandir($dir);
|
||||
if ($items === false) {
|
||||
return;
|
||||
}
|
||||
foreach ($items as $item) {
|
||||
if ($item === '.' || $item === '..') {
|
||||
continue;
|
||||
}
|
||||
$path = $dir . DIRECTORY_SEPARATOR . $item;
|
||||
if (is_dir($path) && !is_link($path)) {
|
||||
self::removeDir($path);
|
||||
} else {
|
||||
@unlink($path);
|
||||
}
|
||||
}
|
||||
@rmdir($dir);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,12 +149,46 @@ class PHPUnit_Smarty extends PHPUnit\Framework\TestCase
|
||||
public function __construct($name = null, array $data = array(), $dataName = '')
|
||||
{
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
if (!defined('individualFolders')) {
|
||||
define('individualFolders', true);
|
||||
}
|
||||
parent::__construct($name, $data, $dataName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the temp directory base for a given test directory.
|
||||
*
|
||||
* Returns a path unique to this test class run under sys_get_temp_dir(),
|
||||
* so that concurrent or sequential runs of different test classes never
|
||||
* share compiled/cached output. The unique token is generated once per
|
||||
* class lifetime and reset in tearDownAfterClass().
|
||||
*
|
||||
* Example:
|
||||
* /path/to/smarty/tests/UnitTests/TagTests/If
|
||||
* → /tmp/smarty-tests/UnitTests/TagTests/If/<unique-id>/
|
||||
*
|
||||
* @param string $dir absolute test directory
|
||||
* @return string absolute temp base directory (with trailing separator)
|
||||
*/
|
||||
private static function getTempDir($dir)
|
||||
{
|
||||
// Lazily generate a unique token for this test class.
|
||||
if (self::$tempId === null) {
|
||||
self::$tempId = uniqid('', true);
|
||||
}
|
||||
$testsRoot = realpath(__DIR__);
|
||||
$realDir = realpath($dir) ?: $dir;
|
||||
// compute relative path from tests/ root
|
||||
if (strpos($realDir, $testsRoot) === 0) {
|
||||
$relative = substr($realDir, strlen($testsRoot));
|
||||
} else {
|
||||
// fallback: use full path hash
|
||||
$relative = DIRECTORY_SEPARATOR . md5($realDir);
|
||||
}
|
||||
return rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR)
|
||||
. DIRECTORY_SEPARATOR . 'smarty-tests'
|
||||
. $relative
|
||||
. DIRECTORY_SEPARATOR . self::$tempId
|
||||
. DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Smarty instance called for each test
|
||||
*
|
||||
@@ -102,47 +196,37 @@ class PHPUnit_Smarty extends PHPUnit\Framework\TestCase
|
||||
*/
|
||||
public function setUpSmarty($dir)
|
||||
{
|
||||
static $s_dir;
|
||||
// set up current working directory
|
||||
chdir($dir);
|
||||
self::$cwd = getcwd();
|
||||
// compute temp base for this test directory
|
||||
self::$tempBase = self::getTempDir($dir);
|
||||
// create missing folders for test
|
||||
if (self::$init) {
|
||||
if (!is_dir($dir . '/templates')) {
|
||||
mkdir($dir . '/templates');
|
||||
if (!is_dir(self::$tempBase . 'templates_c')) {
|
||||
mkdir(self::$tempBase . 'templates_c', 0775, true);
|
||||
}
|
||||
if (!is_dir($dir . '/configs')) {
|
||||
mkdir($dir . '/configs');
|
||||
}
|
||||
if (individualFolders != 'true') {
|
||||
if (!isset($s_dir[ $dir ])) {
|
||||
$this->cleanDir($dir . '/templates_c');
|
||||
$this->cleanDir($dir . '/cache');
|
||||
if (is_dir($dir . '/templates_tmp')) {
|
||||
$this->cleanDir($dir . '/templates_tmp');
|
||||
}
|
||||
$s_dir[ $dir ] = true;
|
||||
}
|
||||
$dir = __DIR__;
|
||||
}
|
||||
if (!is_dir($dir . '/templates_c')) {
|
||||
mkdir($dir . '/templates_c');
|
||||
}
|
||||
chmod($dir . '/templates_c', 0775);
|
||||
if (!is_dir($dir . '/cache')) {
|
||||
mkdir($dir . '/cache');
|
||||
chmod($dir . '/cache', 0775);
|
||||
if (!is_dir(self::$tempBase . 'cache')) {
|
||||
mkdir(self::$tempBase . 'cache', 0775, true);
|
||||
}
|
||||
if (!is_dir(self::$tempBase . 'templates_tmp')) {
|
||||
mkdir(self::$tempBase . 'templates_tmp', 0775, true);
|
||||
}
|
||||
self::$init = false;
|
||||
}
|
||||
clearstatcache();
|
||||
|
||||
// instance Smarty class
|
||||
$this->smarty = new \Smarty\Smarty();
|
||||
if (individualFolders != 'true') {
|
||||
$this->smarty->setCompileDir(__DIR__ . '/templates_c');
|
||||
$this->smarty->setCacheDir(__DIR__ . '/cache');
|
||||
$this->smarty->setCompileDir(self::getTempBase() . 'templates_c');
|
||||
$this->smarty->setCacheDir(self::getTempBase() . 'cache');
|
||||
$this->smarty->addTemplateDir(self::getTempBase() . 'templates_tmp');
|
||||
|
||||
// Clean output dirs once at the start of each test class run
|
||||
if (self::$testNumber === 0) {
|
||||
$this->cleanDirs();
|
||||
}
|
||||
self::$testNumber++;
|
||||
|
||||
}
|
||||
|
||||
@@ -230,24 +314,24 @@ KEY `name` (`name`)
|
||||
{
|
||||
$this->cleanCompileDir();
|
||||
$this->cleanCacheDir();
|
||||
if (is_dir(self::$cwd . '/templates_tmp')) {
|
||||
$this->cleanDir(self::$cwd . '/templates_tmp');
|
||||
$templatesTmpDir = self::getTempBase() . 'templates_tmp';
|
||||
if (is_dir($templatesTmpDir)) {
|
||||
$this->cleanDir($templatesTmpDir);
|
||||
}
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make temporary template file
|
||||
*
|
||||
*/
|
||||
public function makeTemplateFile($name, $code)
|
||||
protected function makeTemplateFile($name, $code)
|
||||
{
|
||||
if (!is_dir(self::$cwd . '/templates_tmp')) {
|
||||
mkdir(self::$cwd . '/templates_tmp');
|
||||
chmod(self::$cwd . '/templates_tmp', 0775);
|
||||
}
|
||||
$fileName = self::$cwd . '/templates_tmp/' . "{$name}";
|
||||
file_put_contents($fileName, $code);
|
||||
file_put_contents(self::getTempBase() . 'templates_tmp' . '/' . $name, $code);
|
||||
}
|
||||
|
||||
protected function removeTemplateFile($name)
|
||||
{
|
||||
unlink(self::getTempBase() . 'templates_tmp' . '/' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,10 +375,8 @@ KEY `name` (`name`)
|
||||
}
|
||||
// directory ?
|
||||
if ($file->isDir()) {
|
||||
if (!$ri->isDot()) {
|
||||
// delete folder if empty
|
||||
@rmdir($file->getPathname());
|
||||
}
|
||||
// delete folder if empty
|
||||
@rmdir($file->getPathname());
|
||||
} else {
|
||||
unlink($file->getPathname());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ class TemplateNormalizationTest extends PHPUnit_Smarty
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->setTemplateDir(__DIR__ . '/templates');
|
||||
}
|
||||
|
||||
public function testGetTemplateDir()
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -18,10 +18,6 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
/**
|
||||
* Test Error suppression template fetched by Smarty object
|
||||
*/
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -21,10 +21,6 @@ class FilterTest extends PHPUnit_Smarty
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* test loaded filter
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -20,10 +20,6 @@ class GetterSetterTest extends PHPUnit_Smarty
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* test setter on Smarty object
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -24,10 +24,6 @@ class DefaultPluginHandlerTest extends PHPUnit_Smarty
|
||||
}
|
||||
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
public function testDefaultFunctionScript()
|
||||
{
|
||||
$this->assertEquals("scriptfunction foo bar", $this->smarty->fetch('test_default_function_script.tpl'));
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -21,10 +21,6 @@ class HttpModifiedSinceTest extends PHPUnit_Smarty
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty PHPunit tests for cache resource Apc
|
||||
*
|
||||
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
include_once __DIR__ . '/../Memcache/CacheResourceCustomMemcacheTest.php';
|
||||
include_once __DIR__ . '/../_shared/PHPunitplugins/cacheresource.apctest.php';
|
||||
|
||||
/**
|
||||
* class for cache resource file tests
|
||||
*
|
||||
*
|
||||
* @preserveGlobalState disabled
|
||||
*
|
||||
*/
|
||||
class CacheResourceCustomApcTest extends CacheResourceCustomMemcacheTest
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
if (!function_exists('apc_cache_info') || ini_get('apc.enable_cli')) {
|
||||
$this->markTestSkipped('APC cache not available');
|
||||
}
|
||||
$this->setUpSmarty(__DIR__);
|
||||
parent::setUp();
|
||||
$this->smarty->setCachingType('apc');
|
||||
$this->smarty->registerCacheResource('apc', new Smarty_CacheResource_Apctest());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,6 @@ class CacheResourceFileTest extends CacheResourceTestCommon
|
||||
}
|
||||
|
||||
|
||||
public function testInit()
|
||||
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* test getCachedFilepath with configuration['useSubDirs'] enabled
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -32,10 +32,6 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon
|
||||
$this->smarty->setCachingType('memcachetest');
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
protected function doClearCacheAssertion($a, $b)
|
||||
{
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -29,15 +29,11 @@ if (MysqlCacheEnable == true) {
|
||||
$this->getConnection();
|
||||
}
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->initMysqlCache();
|
||||
parent::setUp();
|
||||
$this->smarty->setCachingType('mysqltest');
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
$this->initMysqlCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -28,15 +28,11 @@ class CacheResourceCustomPDOTest extends CacheResourceTestCommon
|
||||
$this->getConnection();
|
||||
}
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->initMysqlCache();
|
||||
parent::setUp();
|
||||
$this->smarty->registerCacheResource('pdo',
|
||||
new Smarty_CacheResource_Pdotest($this->getPDO(), 'output_cache'));
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
$this->initMysqlCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use Smarty\Template\Cached;
|
||||
|
||||
require_once __DIR__ . '/../../__shared/cacheresources/cacheresource.pdo.php';
|
||||
require_once __DIR__ . '/../_shared/cacheresources/cacheresource.pdo.php';
|
||||
|
||||
class Smarty_CacheResource_Pdotest extends Smarty_CacheResource_Pdo
|
||||
{
|
||||
|
||||
@@ -27,16 +27,12 @@ class CacheResourceCustomPDOGzipTest extends CacheResourceTestCommon
|
||||
$this->getConnection();
|
||||
}
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->initMysqlCache();
|
||||
parent::setUp();
|
||||
$this->smarty->setCachingType('pdo');
|
||||
$this->smarty->registerCacheResource('pdo', new Smarty_CacheResource_Pdo_Gziptest($this->getPDO(),
|
||||
'output_cache'));
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
$this->initMysqlCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use Smarty\Template\Cached;
|
||||
|
||||
require_once __DIR__ . '/../../__shared/cacheresources/cacheresource.pdo_gzip.php';
|
||||
require_once __DIR__ . '/../_shared/cacheresources/cacheresource.pdo_gzip.php';
|
||||
|
||||
class Smarty_CacheResource_Pdo_Gziptest extends Smarty_CacheResource_Pdo_Gzip
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ if (MysqlCacheEnable == true) {
|
||||
$this->getConnection();
|
||||
}
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->initMysqlCache();
|
||||
parent::setUp();
|
||||
if (!class_exists('Smarty_CacheResource_Mysqltest', false)) {
|
||||
require_once(__DIR__ . "/../_shared/PHPunitplugins/cacheresource.mysqltest.php");
|
||||
@@ -34,11 +35,6 @@ if (MysqlCacheEnable == true) {
|
||||
$this->smarty->registerCacheResource('foobar', new Smarty_CacheResource_Mysqltest());
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
$this->initMysqlCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Smarty\Smarty;
|
||||
use Smarty\Template;
|
||||
use Smarty\Template\Cached;
|
||||
|
||||
require_once __DIR__ . '/../../../__shared/cacheresources/cacheresource.apc.php';
|
||||
|
||||
class Smarty_CacheResource_Apctest extends Smarty_CacheResource_Apc
|
||||
{
|
||||
public $lockTime = 0;
|
||||
|
||||
public function hasLock(Smarty $smarty, Cached $cached)
|
||||
{
|
||||
if ($this->lockTime) {
|
||||
$this->lockTime--;
|
||||
if (!$this->lockTime) {
|
||||
$this->releaseLock($smarty, $cached);
|
||||
}
|
||||
}
|
||||
return parent::hasLock($smarty, $cached);
|
||||
}
|
||||
|
||||
public function get(Template $_template)
|
||||
{
|
||||
$this->contents = array();
|
||||
$this->timestamps = array();
|
||||
$t = $this->getContent($_template);
|
||||
|
||||
return $t ? $t : null;
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
use Smarty\Template;
|
||||
use Smarty\Template\Cached;
|
||||
|
||||
require_once __DIR__ . '/../../../__shared/cacheresources/cacheresource.memcache.php';
|
||||
require_once __DIR__ . '/../cacheresources/cacheresource.memcache.php';
|
||||
|
||||
class Smarty_CacheResource_Memcachetest extends Smarty_CacheResource_Memcache
|
||||
{
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
use Smarty\Exception;
|
||||
use Smarty\Template\Cached;
|
||||
|
||||
require_once __DIR__ . '/../../../__shared/cacheresources/cacheresource.mysql.php';
|
||||
require_once __DIR__ . '/../cacheresources/cacheresource.mysql.php';
|
||||
|
||||
class Smarty_CacheResource_Mysqltest extends Smarty_CacheResource_Mysql
|
||||
{
|
||||
|
||||
@@ -20,10 +20,6 @@ class CompileCompilerPluginTest extends PHPUnit_Smarty
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* test compiler plugin tag in template file
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -17,13 +17,9 @@ class AutoliteralTest extends PHPUnit_Smarty
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->addPluginsDir("../../__shared/PHPunitplugins/");
|
||||
$this->smarty->addPluginsDir("./plugins/");
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* test '{ ' delimiter
|
||||
|
||||
@@ -20,10 +20,6 @@ class DelimiterTest extends PHPUnit_Smarty
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* test <{ }> delimiter
|
||||
|
||||
@@ -17,17 +17,9 @@ class UserliteralTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
if (!property_exists('Smarty', 'literals')) {
|
||||
$this->markTestSkipped('user literal support');
|
||||
} else {
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
public function testUserLiteral()
|
||||
{
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -28,10 +28,6 @@ class ConfigVarTest extends PHPUnit_Smarty
|
||||
/**
|
||||
* empty templat_c and cache folders
|
||||
*/
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* test number config variable
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -25,10 +25,6 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty
|
||||
// Smarty::$_resource_cache = array();
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
protected function relative($path)
|
||||
{
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
+1
-5
@@ -6,7 +6,7 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../../__shared/resources/resource.extendsall.php';
|
||||
require_once __DIR__ . '/resources/resource.extendsall.php';
|
||||
|
||||
/**
|
||||
* class for demo resource plugin extendsall tests
|
||||
@@ -22,10 +22,6 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* test extendsall
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -24,17 +24,9 @@ if (MysqlResourceEnable == true) {
|
||||
$this->getConnection();
|
||||
}
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->addPluginsDir("./PHPunitplugins/");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
$this->initMysqlResource();
|
||||
PHPUnit_Smarty::$pdo->exec("REPLACE INTO templates (name, source) VALUES ('test.tpl', '{\$x = \'hello world\'}{\$x}')");
|
||||
$this->smarty->addPluginsDir("./PHPunitplugins/");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -23,10 +23,6 @@ class DefaultTemplateHandlerTest extends PHPUnit_Smarty
|
||||
}
|
||||
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
/**
|
||||
* test error on unknow template
|
||||
*/
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -21,10 +21,6 @@ class EvalResourceTest extends PHPUnit_Smarty
|
||||
}
|
||||
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
/**
|
||||
* test template eval exits
|
||||
*/
|
||||
@@ -69,15 +65,6 @@ class EvalResourceTest extends PHPUnit_Smarty
|
||||
$this->assertEquals('', $this->smarty->fetch($tpl));
|
||||
}
|
||||
|
||||
/**
|
||||
* test usesCompiler
|
||||
*/
|
||||
public function testUsesCompiler()
|
||||
{
|
||||
$tpl = $this->smarty->createTemplate('eval:hello world');
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* test isEvaluated
|
||||
*/
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -20,10 +20,6 @@ class ExtendsResourceTest extends PHPUnit_Smarty
|
||||
}
|
||||
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
public function compiledPrefilter($text, Template $tpl)
|
||||
{
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -23,10 +23,6 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$this->smarty->enableSecurity();
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
protected function relative($path)
|
||||
{
|
||||
@@ -90,12 +86,6 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$this->assertEquals('hello world', $tpl->getSource()->getContent());
|
||||
}
|
||||
|
||||
public function testUsesCompiler()
|
||||
{
|
||||
$tpl = $this->smarty->createTemplate('helloworld.tpl');
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
public function testIsEvaluated()
|
||||
{
|
||||
$tpl = $this->smarty->createTemplate('helloworld.tpl');
|
||||
@@ -171,8 +161,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$tpl->fetch();
|
||||
$timestamp = $tpl->getCached()->timestamp;
|
||||
|
||||
|
||||
$this->smarty = new \Smarty\Smarty();
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->caching = true;
|
||||
$this->smarty->cache_lifetime = 1000;
|
||||
|
||||
@@ -271,8 +260,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$cwd = getcwd();
|
||||
chdir(__DIR__ . '/templates/sub/');
|
||||
$dn = __DIR__;
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setCompileDir(self::getTempBase() . 'templates_c/');
|
||||
$this->smarty->setCacheDir(self::getTempBase() . 'cache/');
|
||||
$this->smarty->setTemplateDir(array(
|
||||
__DIR__ . '/does-not-exist/',
|
||||
));
|
||||
@@ -292,8 +281,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$cwd = getcwd();
|
||||
chdir(__DIR__ . '/templates/sub/');
|
||||
$dn = __DIR__;
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setCompileDir(self::getTempBase() . 'templates_c/');
|
||||
$this->smarty->setCacheDir(self::getTempBase() . 'cache/');
|
||||
$this->smarty->setTemplateDir(array(
|
||||
__DIR__ . '/does-not-exist/',
|
||||
));
|
||||
@@ -348,8 +337,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
|
||||
$cwd = getcwd();
|
||||
$dn = __DIR__;
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setCompileDir(self::getTempBase() . 'templates_c/');
|
||||
$this->smarty->setCacheDir(self::getTempBase() . 'cache/');
|
||||
$this->smarty->setTemplateDir(array($dn . '/templates/relativity/theory/',));
|
||||
|
||||
$map = array('foo.tpl' => 'theory', './foo.tpl' => 'theory', '././foo.tpl' => 'theory',
|
||||
@@ -367,8 +356,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
|
||||
$cwd = getcwd();
|
||||
$dn = __DIR__;
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setCompileDir(self::getTempBase() . 'templates_c/');
|
||||
$this->smarty->setCacheDir(self::getTempBase() . 'cache/');
|
||||
|
||||
|
||||
$this->smarty->setTemplateDir(array(
|
||||
@@ -399,8 +388,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$cwd = getcwd();
|
||||
$dn = __DIR__;
|
||||
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setCompileDir(self::getTempBase() . 'templates_c/');
|
||||
$this->smarty->setCacheDir(self::getTempBase() . 'cache/');
|
||||
chdir($dn . '/templates/relativity/theory/');
|
||||
$this->smarty->setTemplateDir(array(
|
||||
$dn . '/templates/',
|
||||
@@ -428,8 +417,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$cwd = getcwd();
|
||||
$dn = __DIR__;
|
||||
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setCompileDir(self::getTempBase() . 'templates_c/');
|
||||
$this->smarty->setCacheDir(self::getTempBase() . 'cache/');
|
||||
$this->smarty->setTemplateDir(array($dn . '/templates/relativity/theory/einstein/',));
|
||||
|
||||
$map = array('foo.tpl' => 'einstein', './foo.tpl' => 'einstein', '././foo.tpl' => 'einstein',
|
||||
@@ -448,8 +437,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$cwd = getcwd();
|
||||
$dn = __DIR__;
|
||||
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setCompileDir(self::getTempBase() . 'templates_c/');
|
||||
$this->smarty->setCacheDir(self::getTempBase() . 'cache/');
|
||||
$this->smarty->setTemplateDir(array(
|
||||
$dn . '/templates/relativity/theory/einstein/',
|
||||
));
|
||||
@@ -479,8 +468,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$cwd = getcwd();
|
||||
$dn = __DIR__;
|
||||
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setCompileDir(self::getTempBase() . 'templates_c/');
|
||||
$this->smarty->setCacheDir(self::getTempBase() . 'cache/');
|
||||
$this->smarty->setTemplateDir(array('../..',));
|
||||
|
||||
$map = array('foo.tpl' => 'relativity', './foo.tpl' => 'relativity', '././foo.tpl' => 'relativity',);
|
||||
@@ -497,8 +486,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$cwd = getcwd();
|
||||
$dn = __DIR__;
|
||||
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setCompileDir(self::getTempBase() . 'templates_c/');
|
||||
$this->smarty->setCacheDir(self::getTempBase() . 'cache/');
|
||||
$this->smarty->setTemplateDir(array('../..',));
|
||||
|
||||
$map =
|
||||
@@ -516,8 +505,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$cwd = getcwd();
|
||||
$dn = __DIR__;
|
||||
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setCompileDir(self::getTempBase() . 'templates_c/');
|
||||
$this->smarty->setCacheDir(self::getTempBase() . 'cache/');
|
||||
$this->smarty->setTemplateDir(array(
|
||||
'../..',
|
||||
));
|
||||
@@ -549,8 +538,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
|
||||
$cwd = getcwd();
|
||||
$dn = __DIR__;
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setCompileDir(self::getTempBase() . 'templates_c/');
|
||||
$this->smarty->setCacheDir(self::getTempBase() . 'cache/');
|
||||
$this->smarty->setTemplateDir(array(
|
||||
'..',
|
||||
));
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -14,16 +14,13 @@ class FileResourceIndexedTest extends PHPUnit_Smarty
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->setTemplateDir(__DIR__ . '/templates');
|
||||
$this->smarty->addTemplateDir(__DIR__ . '/templates_2');
|
||||
// note that 10 is a string!
|
||||
$this->smarty->addTemplateDir(__DIR__ . '/templates_3', '10');
|
||||
$this->smarty->addTemplateDir(__DIR__ . '/templates_4', 'foo');
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
public function testFetch()
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user