Skip to content

Commit 97a594e

Browse files
committed
Created a helper for boolean variables
1 parent bc05948 commit 97a594e

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace PE\Helpers\NodeVariables;
4+
5+
use PE\Nodes\EncoderNodeVariable;
6+
use PE\Variables\Types\ObjectGetter;
7+
use PE\Variables\Types\ObjectSetter;
8+
9+
class EncoderNodeVariableBool extends EncoderNodeVariable {
10+
11+
function __construct($id, $method) {
12+
parent::__construct($id, false);
13+
14+
$this->setType(EncoderNodeVariable::TYPE_BOOL);
15+
16+
$this->objectSetter(new ObjectSetter($method));
17+
$this->objectGetter(new ObjectGetter($method));
18+
}
19+
}
20+
?>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace PE\Tests\Nodes\Children;
4+
5+
use PE\Helpers\NodeVariables\EncoderNodeVariableBool;
6+
use PE\Nodes\EncoderNodeVariable;
7+
use PE\Tests\Samples;
8+
9+
class EncoderNodeVariableBoolTest extends Samples
10+
{
11+
12+
protected function setUp()
13+
{
14+
parent::setUp();
15+
$this->_peApp = new EncoderNodeVariableBool('method', 'isTest');
16+
}
17+
18+
/**
19+
* @return EncoderNodeVariableBool
20+
*/
21+
protected function variable()
22+
{
23+
return $this->_peApp;
24+
}
25+
26+
public function testConstructor()
27+
{
28+
$boolVariable = new EncoderNodeVariableBool('test', 'isTest');
29+
$this->assertNotNull($boolVariable);
30+
$this->assertTrue($boolVariable instanceof EncoderNodeVariableBool);
31+
32+
$this->assertEquals(EncoderNodeVariable::TYPE_BOOL, $boolVariable->getType());
33+
$this->assertEquals('isTest', $boolVariable->getObjectSetter()->getMethod());
34+
$this->assertEquals('isTest', $boolVariable->getObjectGetter()->getMethod());
35+
}
36+
}
37+
?>

0 commit comments

Comments
 (0)