public function testRenderBootstrapFormWithTraversal()
    {
        $bootstrapForm = '<form class="form-horizontal" >
<div class="form-group" >
<label for="inputEmail3" class="col-sm-2 control-label" >Email</label>
<div class="col-sm-10" >
<input type="email" class="form-control" id="inputEmail3" placeholder="Email" value="{{ model.email }}" />
</div>
</div>
<div class="form-group" >
<label for="inputPassword3" class="col-sm-2 control-label" >Password</label>
<div class="col-sm-10" >
<input type="password" class="form-control" id="inputPassword3" placeholder="Password" />
</div>
</div>
<div class="form-group" >
<div class="col-sm-offset-2 col-sm-10" >
<button type="submit" class="btn btn-default" onclick="" >Sign In</button>
</div>
</div>
</form>';
        $bootstrapForm = str_replace("\n", "", $bootstrapForm);
        $bootstrapForm = str_replace("\r", "", $bootstrapForm);
        $factory = new Factory();
        //bootstrap factory
        $email = $factory->makeFormInput('Email', 'email', 'inputEmail3', 'Email');
        //Traverse the Structure to get the Input Element
        $email->getChild(1)->getChild(0)->setAttribute('value', '{{ model.email }}');
        $form = (new Form())->setAttribute('class', 'form-horizontal')->addChild($email)->addChild($factory->makeFormInput('Password', 'password', 'inputPassword3', 'Password'))->addChild($factory->makeButton('Sign In'));
        $this->assertEquals($bootstrapForm, $form->render());
    }
 public function testSetData()
 {
     $factory = new Factory();
     //bootstrap factory
     //Make Email field
     $email = $factory->makeFormInput('Email', 'email', 'inputEmail3', 'Email');
     $email->getChild(1)->getChild(0)->setAttribute('name', 'email');
     //Make password
     $password = $factory->makeFormInput('Password', 'password', 'inputPassword3', 'Password');
     $password->getChild(1)->getChild(0)->setAttribute('name', 'password');
     $form = (new Form())->setAttribute('class', 'form-horizontal')->addChild($email)->addChild($password)->addChild($factory->makeButton('Sign In'))->setData(["email" => '*****@*****.**', "password" => "123456"]);
     $this->assertEquals("*****@*****.**", $email->getChild(1)->getChild(0)->getAttribute('value'));
     $this->assertEquals("123456", $password->getChild(1)->getChild(0)->getAttribute('value'));
 }
 public function testGenerator()
 {
     $factory = new Factory();
     //bootstrap factory
     $form = (new Form())->setAttribute('class', 'form-horizontal')->addChild($factory->makeFormInput('Email', 'email', 'inputEmail3', 'Email'))->addChild($factory->makeFormInput('Password', 'password', 'inputPassword3', 'Password'))->addChild($factory->makeFormInput('testSelect', 'select', 'select4', '', [['name' => 'one', 'value' => 1], ['name' => 'two', 'value' => 2]]))->addChild($factory->makeButton('Sign In'));
     $elements = $form->getAllElementsOfType('input');
     /** @var $input Element */
     foreach ($elements as $input) {
         $input->setAttribute('value', isset($element['value']) ? $element['value'] : "");
     }
     $generator = new Generator($factory);
     $form2 = $generator->generate([['label' => 'Email', 'type' => 'email', 'id' => 'inputEmail3', 'placeholder' => 'Email'], ['label' => 'Password', 'type' => 'password', 'id' => 'inputPassword3', 'placeholder' => 'Password'], ['label' => 'testSelect', 'type' => 'select', 'id' => 'select4', 'placeholder' => '', 'options' => [['name' => 'one', 'value' => 1], ['name' => 'two', 'value' => 2]]]], 'Sign In');
     $this->assertEquals($form->render(), $form2->render());
 }