123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace Codeception\Util;
- class TemplateTest extends \PHPUnit\Framework\TestCase
- {
- public function testTemplateCanPassValues()
- {
- $template = new Template("hello, {{name}}");
- $template->place('name', 'davert');
- $this->assertEquals('hello, davert', $template->produce());
- }
- public function testTemplateCanHaveOtherPlaceholder()
- {
- $template = new Template("hello, %name%", '%', '%');
- $template->place('name', 'davert');
- $this->assertEquals('hello, davert', $template->produce());
- }
- public function testTemplateSupportsDotNotationForArrays()
- {
- $template = new Template("hello, {{user.data.name}}");
- $template->place('user', ['data' => ['name' => 'davert']]);
- $this->assertEquals('hello, davert', $template->produce());
- }
- public function testShouldSkipUnmatchedPlaceholder()
- {
- $template = new Template("hello, {{name}}");
- $this->assertEquals('hello, {{name}}', $template->produce());
- }
- }
|