This repository has been archived by the owner on Feb 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b287cbe
commit 9490c55
Showing
1 changed file
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -426,19 +426,40 @@ public function testRenderFileGroupWithError() | |
$this->assertEquals($expected, $result); | ||
} | ||
|
||
public function testCanAddClassToUnderlyingControl() | ||
{ | ||
public function testCanAddClassToUnderlyingControl() | ||
{ | ||
$expected = '<div class="form-group"><label class="control-label" for="color">Favorite Color</label><select name="color" id="color" class="form-control my-class"><option value="1">Red</option><option value="2">Green</option><option value="3">Blue</option></select></div>'; | ||
|
||
$options = array('1' => 'Red', '2' => 'Green', '3' => 'Blue'); | ||
$result = $this->form->select('Favorite Color', 'color', $options)->addClass('my-class')->render(); | ||
$this->assertEquals($expected, $result); | ||
} | ||
} | ||
|
||
public function testRenderTextGroupWithLabelClass() | ||
public function testRenderTextGroupWithLabelClass() | ||
{ | ||
$expected = '<div class="form-group"><label class="control-label required" for="email">Email</label><input type="text" name="email" id="email" class="form-control"></div>'; | ||
$result = $this->form->text('Email', 'email')->labelClass('required')->render(); | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
public function testBindObject() | ||
{ | ||
$object = $this->getStubObject(); | ||
$this->form->bind($object); | ||
$expected = '<div class="form-group"><label class="control-label" for="first_name">First Name</label><input type="text" name="first_name" value="John" id="first_name" class="form-control"></div>'; | ||
$result = $this->form->text('First Name', 'first_name')->render(); | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
private function getStubObject() | ||
{ | ||
$obj = new stdClass; | ||
$obj->email = '[email protected]'; | ||
$obj->first_name = 'John'; | ||
$obj->last_name = 'Doe'; | ||
$obj->date_of_birth = new \DateTime('1985-05-06'); | ||
$obj->gender = 'male'; | ||
$obj->terms = 'agree'; | ||
return $obj; | ||
} | ||
} |