Skip to content

Commit

Permalink
used new testbench's feature
Browse files Browse the repository at this point in the history
  • Loading branch information
konecnyjakub committed Nov 7, 2016
1 parent 5e5ff0f commit c898e94
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 38 deletions.
26 changes: 13 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 4 additions & 25 deletions tests/Nexendrie/BookComponent/BookControlTest.phpt
@@ -1,8 +1,7 @@
<?php
namespace Nexendrie\BookComponent;

use Nette\ComponentModel\IComponent,
Tester\Assert,
use Tester\Assert,
Nexendrie\Translation\Translator;

require __DIR__ . "/../../bootstrap.php";
Expand Down Expand Up @@ -37,26 +36,6 @@ class BookControlTest extends \Tester\TestCase {

use \Testbench\TComponent;

/**
* @param IComponent $control
* @param $expected
* @param string $page
* @return void
*/
protected function checkRenderOutput(IComponent $control, $expected, $page = "index") {
/** @var BookControl $control */
if(!$control->getParent()) {
$this->attachToPresenter($control);
}
ob_start();
$control->render($page);
if(is_file($expected)) {
Assert::matchFile($expected, ob_get_clean());
} else {
Assert::match($expected, ob_get_clean());
}
}

function setUp() {
$this->control = new BookControl2;
$this->attachToPresenter($this->control);
Expand Down Expand Up @@ -84,17 +63,17 @@ class BookControlTest extends \Tester\TestCase {

function testRenderP1() {
$filename = __DIR__ . "/bookPageExpected1.latte";
$this->checkRenderOutput($this->control, $filename, "slug1");
$this->checkRenderOutput($this->control, $filename, ["page" => "slug1"]);
}

function testRenderP2() {
$filename = __DIR__ . "/bookPageExpected2.latte";
$this->checkRenderOutput($this->control, $filename, "slug2");
$this->checkRenderOutput($this->control, $filename, ["page" => "slug2"]);
}

function testRenderP3() {
$filename = __DIR__ . "/bookPageExpected3.latte";
$this->checkRenderOutput($this->control, $filename, "slug3");
$this->checkRenderOutput($this->control, $filename, ["page" => "slug3"]);
}
}

Expand Down

0 comments on commit c898e94

Please sign in to comment.