Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b7c357e78 | ||
|
|
7ea28eea5e | ||
|
|
3ff2b89ea4 | ||
|
|
7c02a4f0fd | ||
|
|
3617dac0c4 | ||
|
|
de73798e3e | ||
|
|
59f124084c | ||
|
|
0f4473f9a0 | ||
|
|
af7663294a | ||
|
|
fb7693cf4b | ||
|
|
9c4fea1f04 | ||
|
|
c93974c835 | ||
|
|
501aea5374 | ||
|
|
72d6ea9713 | ||
|
|
5edfe5d8bb | ||
|
|
42a626c23e | ||
|
|
f6d0f1c5c4 | ||
|
|
ebe5123467 |
No files matched your search
+1101
-989
File diff suppressed because it is too large.
Load diff
+3
-3
@@ -96,7 +96,7 @@ class HtmlBuilder {
|
|||||||
|
|
||||||
return '<img src="'.$this->url->asset($url, $secure).'"'.$this->attributes($attributes).'>';
|
return '<img src="'.$this->url->asset($url, $secure).'"'.$this->attributes($attributes).'>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a link to a Favicon file.
|
* Generate a link to a Favicon file.
|
||||||
*
|
*
|
||||||
@@ -313,7 +313,7 @@ class HtmlBuilder {
|
|||||||
*
|
*
|
||||||
* @param mixed $key
|
* @param mixed $key
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $value
|
* @param mixed $value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function listingElement($key, $type, $value)
|
protected function listingElement($key, $type, $value)
|
||||||
@@ -333,7 +333,7 @@ class HtmlBuilder {
|
|||||||
*
|
*
|
||||||
* @param mixed $key
|
* @param mixed $key
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $value
|
* @param mixed $value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function nestedListing($key, $type, $value)
|
protected function nestedListing($key, $type, $value)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use Collective\Html\FormBuilder;
|
|||||||
use Collective\Html\HtmlBuilder;
|
use Collective\Html\HtmlBuilder;
|
||||||
use Illuminate\Routing\UrlGenerator;
|
use Illuminate\Routing\UrlGenerator;
|
||||||
use Illuminate\Routing\RouteCollection;
|
use Illuminate\Routing\RouteCollection;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
class FormBuilderTest extends PHPUnit_Framework_TestCase {
|
class FormBuilderTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
@@ -183,6 +184,18 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testFormTel()
|
||||||
|
{
|
||||||
|
$form1 = $this->formBuilder->tel('foo');
|
||||||
|
$form2 = $this->formBuilder->tel('foo', 'foobar');
|
||||||
|
$form3 = $this->formBuilder->tel('foo', null, ['class' => 'span2']);
|
||||||
|
|
||||||
|
$this->assertEquals('<input name="foo" type="tel">', $form1);
|
||||||
|
$this->assertEquals('<input name="foo" type="tel" value="foobar">', $form2);
|
||||||
|
$this->assertEquals('<input class="span2" name="foo" type="tel">', $form3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testFormNumber()
|
public function testFormNumber()
|
||||||
{
|
{
|
||||||
$form1 = $this->formBuilder->number('foo');
|
$form1 = $this->formBuilder->number('foo');
|
||||||
@@ -207,6 +220,17 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals('<input class="span2" name="foo" type="date">', $form4);
|
$this->assertEquals('<input class="span2" name="foo" type="date">', $form4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFormTime()
|
||||||
|
{
|
||||||
|
$form1 = $this->formBuilder->time('foo');
|
||||||
|
$form2 = $this->formBuilder->time('foo', \Carbon\Carbon::now()->format('H:i'));
|
||||||
|
$form3 = $this->formBuilder->time('foo', null, ['class' => 'span2']);
|
||||||
|
|
||||||
|
$this->assertEquals('<input name="foo" type="time">', $form1);
|
||||||
|
$this->assertEquals('<input name="foo" type="time" value="' . \Carbon\Carbon::now()->format('H:i') . '">', $form2);
|
||||||
|
$this->assertEquals('<input class="span2" name="foo" type="time">', $form3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testFormFile()
|
public function testFormFile()
|
||||||
{
|
{
|
||||||
@@ -291,6 +315,24 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals($select, '<select name="size[key]"><option value="L">Large</option><option value="M">Medium</option><option value="S" selected="selected">Small</option></select>');
|
$this->assertEquals($select, '<select name="size[key]"><option value="L">Large</option><option value="M">Medium</option><option value="S" selected="selected">Small</option></select>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFormWithOptionalPlaceholder()
|
||||||
|
{
|
||||||
|
$select = $this->formBuilder->select(
|
||||||
|
'size',
|
||||||
|
['L' => 'Large', 'S' => 'Small'],
|
||||||
|
null,
|
||||||
|
['placeholder' => 'Select One...']
|
||||||
|
);
|
||||||
|
$this->assertEquals($select, '<select name="size"><option selected="selected" value="">Select One...</option><option value="L">Large</option><option value="S">Small</option></select>');
|
||||||
|
|
||||||
|
$select = $this->formBuilder->select(
|
||||||
|
'size',
|
||||||
|
['L' => 'Large', 'S' => 'Small'],
|
||||||
|
'L',
|
||||||
|
['placeholder' => 'Select One...']
|
||||||
|
);
|
||||||
|
$this->assertEquals($select, '<select name="size"><option value="">Select One...</option><option value="L" selected="selected">Large</option><option value="S">Small</option></select>');
|
||||||
|
}
|
||||||
|
|
||||||
public function testFormSelectYear()
|
public function testFormSelectYear()
|
||||||
{
|
{
|
||||||
@@ -368,6 +410,30 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testFormCheckboxWithModelRelation()
|
||||||
|
{
|
||||||
|
$this->formBuilder->setSessionStore($session = m::mock('Illuminate\Session\Store'));
|
||||||
|
$session->shouldReceive('getOldInput')->withNoArgs()->andReturn(array());
|
||||||
|
$session->shouldReceive('getOldInput')->with('items')->andReturn(null);
|
||||||
|
|
||||||
|
$mockModel2 = new StdClass;
|
||||||
|
$mockModel2->id = 2;
|
||||||
|
$mockModel3 = new StdClass;
|
||||||
|
$mockModel3->id = 3;
|
||||||
|
$this->setModel(array('items' => new Collection(array($mockModel2, $mockModel3))));
|
||||||
|
|
||||||
|
$check1 = $this->formBuilder->checkbox('items[]', 1);
|
||||||
|
$check2 = $this->formBuilder->checkbox('items[]', 2);
|
||||||
|
$check3 = $this->formBuilder->checkbox('items[]', 3, false);
|
||||||
|
$check4 = $this->formBuilder->checkbox('items[]', 4, true);
|
||||||
|
|
||||||
|
$this->assertEquals('<input name="items[]" type="checkbox" value="1">', $check1);
|
||||||
|
$this->assertEquals('<input checked="checked" name="items[]" type="checkbox" value="2">', $check2);
|
||||||
|
$this->assertEquals('<input name="items[]" type="checkbox" value="3">', $check3);
|
||||||
|
$this->assertEquals('<input checked="checked" name="items[]" type="checkbox" value="4">', $check4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testFormCheckboxWithoutSession()
|
public function testFormCheckboxWithoutSession()
|
||||||
{
|
{
|
||||||
$form1 = $this->formBuilder->checkbox('foo');
|
$form1 = $this->formBuilder->checkbox('foo');
|
||||||
@@ -474,4 +540,4 @@ class FormBuilderModelStub {
|
|||||||
{
|
{
|
||||||
return isset($this->data[$key]);
|
return isset($this->data[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user