Skip to content
This repository has been archived by the owner on Aug 12, 2019. It is now read-only.

Commit

Permalink
BaseInputMacros: fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Sep 23, 2017
1 parent 4d03208 commit a7c9469
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/cases/BaseInputMacrosTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@

namespace NextrasTests\Forms;

use Latte;
use Nextras\Forms\Bridges\Latte\Macros\BaseInputMacros;
use Tester\Assert;
use Tester\TestCase;
use Latte;


require_once __DIR__ . '/../bootstrap.php';


class MockBaseInputMacros extends BaseInputMacros {}
class MockBaseInputMacros extends BaseInputMacros
{
}


class BaseInputMactrosTest extends TestCase
{

public function testLabel()
{
$latte = new Latte\Engine;
Expand All @@ -26,19 +28,18 @@ class BaseInputMactrosTest extends TestCase

$result = $this->extract($latte->compile('{label foo /}'));
Assert::same(
'$_input = $_form["foo"];if ($_label = $_input->getLabel()) echo NextrasTests\Forms\MockBaseInputMacros::label($_label->addAttributes([]), $_input, false);',
'$_input = end($this->global->formsStack)["foo"];if ($_label = $_input->getLabel()) echo NextrasTests\Forms\MockBaseInputMacros::label($_label->addAttributes([]), $_input, false);',
$result
);

$result = $this->extract($latte->compile('{label foo: /}'));
Assert::same(
'$_input = $_form["foo"];if ($_label = $_input->getLabelPart("")) echo NextrasTests\Forms\MockBaseInputMacros::label($_label->addAttributes([]), $_input, true);',
'$_input = end($this->global->formsStack)["foo"];if ($_label = $_input->getLabelPart("")) echo NextrasTests\Forms\MockBaseInputMacros::label($_label->addAttributes([]), $_input, true);',
$result
);
}



public function testInput()
{
$latte = new Latte\Engine;
Expand All @@ -47,13 +48,13 @@ class BaseInputMactrosTest extends TestCase

$result = $this->extract($latte->compile('{input foo}'));
Assert::same(
'$_input = $_form["foo"];echo NextrasTests\\Forms\\MockBaseInputMacros::input($_input->getControl()->addAttributes([]), $_input, false);',
'$_input = end($this->global->formsStack)["foo"];echo NextrasTests\\Forms\\MockBaseInputMacros::input($_input->getControl()->addAttributes([]), $_input, false);',
$result
);

$result = $this->extract($latte->compile('{input foo:}'));
Assert::same(
'$_input = $_form["foo"];echo NextrasTests\Forms\MockBaseInputMacros::input($_input->getControlPart("")->addAttributes([]), $_input, true);',
'$_input = end($this->global->formsStack)["foo"];echo NextrasTests\Forms\MockBaseInputMacros::input($_input->getControlPart("")->addAttributes([]), $_input, true);',
$result
);
}
Expand All @@ -66,7 +67,6 @@ class BaseInputMactrosTest extends TestCase
$lines = implode('', array_map('trim', $lines));
return $lines;
}

}


Expand Down

0 comments on commit a7c9469

Please sign in to comment.