<?php use Aah\ControlStructures\IfControlStructure; use Aah\Parsers\Parser; describe("Control Structure", function () { beforeEach(function () { $parser = new Parser(); $this->testStructure = $parser->readFile(__DIR__ . '/../TestingAssets/if.aah'); $data = ['name' => 'Matt']; $this->if = new IfControlStructure($this->testStructure, $data); }); describe("::breakdown()", function () { it("passes if it properly breakdowns the structure", function () { expect($this->if->parts['expression'])->toBe("%name == 'Matt'"); }); }); describe("::hasElse()", function () { it("passes if it returns truthy", function () { $result = $this->if->hasElse($this->testStructure); expect($result)->toBeTruthy(); }); }); describe("::hasElseIf()", function () { it("passes if it returns truthy", function () { $result = $this->if->hasElseIf($this->testStructure); expect($result)->toBeTruthy(); }); }); describe("::doIf()", function () { it("passes if it returns falsy", function () { $result = $this->if->doIf('if(true){return true;}');
<?php use Aah\ControlStructures\ForeachControlStructure; use Aah\Parsers\Parser; describe("Control Structure", function () { beforeEach(function () { $parser = new Parser(); $testStructure = $parser->readFile(__DIR__ . '/../TestingAssets/foreach.aah'); $data = ['dogs' => ['Zoe', 'Sadie']]; $this->fe = new ForeachControlStructure($testStructure, $data); }); describe("::breakdown()", function () { it("passes if it properly breakdowns the structure", function () { expect($this->fe->parts['expression'])->toBe('dogs'); expect($this->fe->parts['value'])->toBe('dog'); expect($this->fe->parts['key'])->toBeNull(); expect($this->fe->parts['statement'])->toBe("\n\t+p: %dog\n"); }); }); describe("::perform()", function () { it("passes if it properly breakdowns the structure", function () { $result = $this->fe->perform(); expect($result)->toBe("\n\t+p: Zoe\n\n\t+p: Sadie\n"); }); }); });