Skip to content

Commit

Permalink
Make tests consistent
Browse files Browse the repository at this point in the history
- `s/$template/$renderer/` throughout new tests.
  • Loading branch information
weierophinney committed Oct 10, 2015
1 parent 9964107 commit 5e6561a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
38 changes: 19 additions & 19 deletions test/Template/TwigRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ public function testResolvesNamespacedTemplateWithSuffix()

public function testAddParameterToOneTemplate()
{
$template = new TwigRenderer();
$template->addPath(__DIR__ . '/TestAsset');
$renderer = new TwigRenderer();
$renderer->addPath(__DIR__ . '/TestAsset');
$name = 'Twig';
$template->addDefaultParam('twig', 'name', $name);
$result = $template->render('twig');
$renderer->addDefaultParam('twig', 'name', $name);
$result = $renderer->render('twig');

$content = file_get_contents(__DIR__ . '/TestAsset/twig.html');
$content = str_replace('{{ name }}', $name, $content);
Expand All @@ -191,48 +191,48 @@ public function testAddParameterToOneTemplate()

public function testAddSharedParameters()
{
$template = new TwigRenderer();
$template->addPath(__DIR__ . '/TestAsset');
$renderer = new TwigRenderer();
$renderer->addPath(__DIR__ . '/TestAsset');
$name = 'Twig';
$template->addDefaultParam($template::TEMPLATE_ALL, 'name', $name);
$result = $template->render('twig');
$renderer->addDefaultParam($renderer::TEMPLATE_ALL, 'name', $name);
$result = $renderer->render('twig');
$content = file_get_contents(__DIR__ . '/TestAsset/twig.html');
$content = str_replace('{{ name }}', $name, $content);
$this->assertEquals($content, $result);

$result = $template->render('twig-2');
$result = $renderer->render('twig-2');
$content = file_get_contents(__DIR__ . '/TestAsset/twig-2.html');
$content = str_replace('{{ name }}', $name, $content);
$this->assertEquals($content, $result);
}

public function testOverrideSharedParametersPerTemplate()
{
$template = new TwigRenderer();
$template->addPath(__DIR__ . '/TestAsset');
$renderer = new TwigRenderer();
$renderer->addPath(__DIR__ . '/TestAsset');
$name = 'Twig';
$name2 = 'Template';
$template->addDefaultParam($template::TEMPLATE_ALL, 'name', $name);
$template->addDefaultParam('twig-2', 'name', $name2);
$result = $template->render('twig');
$renderer->addDefaultParam($renderer::TEMPLATE_ALL, 'name', $name);
$renderer->addDefaultParam('twig-2', 'name', $name2);
$result = $renderer->render('twig');
$content = file_get_contents(__DIR__ . '/TestAsset/twig.html');
$content = str_replace('{{ name }}', $name, $content);
$this->assertEquals($content, $result);

$result = $template->render('twig-2');
$result = $renderer->render('twig-2');
$content = file_get_contents(__DIR__ . '/TestAsset/twig-2.html');
$content = str_replace('{{ name }}', $name2, $content);
$this->assertEquals($content, $result);
}

public function testOverrideSharedParametersAtRender()
{
$template = new TwigRenderer();
$template->addPath(__DIR__ . '/TestAsset');
$renderer = new TwigRenderer();
$renderer->addPath(__DIR__ . '/TestAsset');
$name = 'Twig';
$name2 = 'Template';
$template->addDefaultParam($template::TEMPLATE_ALL, 'name', $name);
$result = $template->render('twig', ['name' => $name2]);
$renderer->addDefaultParam($renderer::TEMPLATE_ALL, 'name', $name);
$result = $renderer->render('twig', ['name' => $name2]);
$content = file_get_contents(__DIR__ . '/TestAsset/twig.html');
$content = str_replace('{{ name }}', $name2, $content);
$this->assertEquals($content, $result);
Expand Down
38 changes: 19 additions & 19 deletions test/Template/ZendViewRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ public function testProperlyResolvesNamespacedTemplate()

public function testAddParameterToOneTemplate()
{
$template = new ZendViewRenderer();
$template->addPath(__DIR__ . '/TestAsset');
$renderer = new ZendViewRenderer();
$renderer->addPath(__DIR__ . '/TestAsset');
$name = 'ZendView';
$template->addDefaultParam('zendview', 'name', $name);
$result = $template->render('zendview');
$renderer->addDefaultParam('zendview', 'name', $name);
$result = $renderer->render('zendview');

$content = file_get_contents(__DIR__ . '/TestAsset/zendview.phtml');
$content = str_replace('<?php echo $name ?>', $name, $content);
Expand All @@ -266,48 +266,48 @@ public function testAddParameterToOneTemplate()

public function testAddSharedParameters()
{
$template = new ZendViewRenderer();
$template->addPath(__DIR__ . '/TestAsset');
$renderer = new ZendViewRenderer();
$renderer->addPath(__DIR__ . '/TestAsset');
$name = 'ZendView';
$template->addDefaultParam($template::TEMPLATE_ALL, 'name', $name);
$result = $template->render('zendview');
$renderer->addDefaultParam($renderer::TEMPLATE_ALL, 'name', $name);
$result = $renderer->render('zendview');
$content = file_get_contents(__DIR__ . '/TestAsset/zendview.phtml');
$content = str_replace('<?php echo $name ?>', $name, $content);
$this->assertEquals($content, $result);

$result = $template->render('zendview-2');
$result = $renderer->render('zendview-2');
$content = file_get_contents(__DIR__ . '/TestAsset/zendview-2.phtml');
$content = str_replace('<?php echo $name ?>', $name, $content);
$this->assertEquals($content, $result);
}

public function testOverrideSharedParametersPerTemplate()
{
$template = new ZendViewRenderer();
$template->addPath(__DIR__ . '/TestAsset');
$renderer = new ZendViewRenderer();
$renderer->addPath(__DIR__ . '/TestAsset');
$name = 'Zend';
$name2 = 'View';
$template->addDefaultParam($template::TEMPLATE_ALL, 'name', $name);
$template->addDefaultParam('zendview-2', 'name', $name2);
$result = $template->render('zendview');
$renderer->addDefaultParam($renderer::TEMPLATE_ALL, 'name', $name);
$renderer->addDefaultParam('zendview-2', 'name', $name2);
$result = $renderer->render('zendview');
$content = file_get_contents(__DIR__ . '/TestAsset/zendview.phtml');
$content = str_replace('<?php echo $name ?>', $name, $content);
$this->assertEquals($content, $result);

$result = $template->render('zendview-2');
$result = $renderer->render('zendview-2');
$content = file_get_contents(__DIR__ . '/TestAsset/zendview-2.phtml');
$content = str_replace('<?php echo $name ?>', $name2, $content);
$this->assertEquals($content, $result);
}

public function testOverrideSharedParametersAtRender()
{
$template = new ZendViewRenderer();
$template->addPath(__DIR__ . '/TestAsset');
$renderer = new ZendViewRenderer();
$renderer->addPath(__DIR__ . '/TestAsset');
$name = 'Zend';
$name2 = 'View';
$template->addDefaultParam($template::TEMPLATE_ALL, 'name', $name);
$result = $template->render('zendview', ['name' => $name2]);
$renderer->addDefaultParam($renderer::TEMPLATE_ALL, 'name', $name);
$result = $renderer->render('zendview', ['name' => $name2]);
$content = file_get_contents(__DIR__ . '/TestAsset/zendview.phtml');
$content = str_replace('<?php echo $name ?>', $name2, $content);
$this->assertEquals($content, $result);
Expand Down

0 comments on commit 5e6561a

Please sign in to comment.