Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b7c357e78 | ||
|
|
7ea28eea5e | ||
|
|
3ff2b89ea4 | ||
|
|
7c02a4f0fd | ||
|
|
3617dac0c4 | ||
|
|
de73798e3e | ||
|
|
59f124084c | ||
|
|
0f4473f9a0 | ||
|
|
af7663294a | ||
|
|
fb7693cf4b | ||
|
|
9c4fea1f04 | ||
|
|
c93974c835 | ||
|
|
501aea5374 | ||
|
|
72d6ea9713 | ||
|
|
5edfe5d8bb | ||
|
|
42a626c23e | ||
|
|
0918dac79f | ||
|
|
28a91965be | ||
|
|
f6d0f1c5c4 | ||
|
|
f1eddc7a78 | ||
|
|
745c10226d | ||
|
|
ebe5123467 | ||
|
|
a0a763779d | ||
|
|
c55fda58b1 | ||
|
|
8ae4aa0627 | ||
|
|
e4b32919a3 | ||
|
|
e884f50d1c | ||
|
|
6b023d8055 |
No files matched your search
@@ -1,7 +1,6 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm
|
||||
|
||||
+5
-5
@@ -12,11 +12,11 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"illuminate/http": "~5.0",
|
||||
"illuminate/routing": "~5.0",
|
||||
"illuminate/session": "~5.0",
|
||||
"illuminate/support": "~5.0"
|
||||
"php": ">=5.5.9",
|
||||
"illuminate/http": "5.1.*",
|
||||
"illuminate/routing": "5.1.*",
|
||||
"illuminate/session": "5.1.*",
|
||||
"illuminate/support": "5.1.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9",
|
||||
|
||||
+1101
-996
File diff suppressed because it is too large.
Load diff
+6
-6
@@ -96,7 +96,7 @@ class HtmlBuilder {
|
||||
|
||||
return '<img src="'.$this->url->asset($url, $secure).'"'.$this->attributes($attributes).'>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate a link to a Favicon file.
|
||||
*
|
||||
@@ -313,7 +313,7 @@ class HtmlBuilder {
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param string $type
|
||||
* @param string $value
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
protected function listingElement($key, $type, $value)
|
||||
@@ -333,7 +333,7 @@ class HtmlBuilder {
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param string $type
|
||||
* @param string $value
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
protected function nestedListing($key, $type, $value)
|
||||
@@ -358,9 +358,6 @@ class HtmlBuilder {
|
||||
{
|
||||
$html = array();
|
||||
|
||||
// For numeric keys we will assume that the key and the value are the same
|
||||
// as this will convert HTML attributes such as "required" to a correct
|
||||
// form like required="required" instead of using incorrect numerics.
|
||||
foreach ((array) $attributes as $key => $value)
|
||||
{
|
||||
$element = $this->attributeElement($key, $value);
|
||||
@@ -380,6 +377,9 @@ class HtmlBuilder {
|
||||
*/
|
||||
protected function attributeElement($key, $value)
|
||||
{
|
||||
// For numeric keys we will assume that the key and the value are the same
|
||||
// as this will convert HTML attributes such as "required" to a correct
|
||||
// form like required="required" instead of using incorrect numerics.
|
||||
if (is_numeric($key)) $key = $value;
|
||||
|
||||
if ( ! is_null($value)) return $key.'="'.e($value).'"';
|
||||
|
||||
@@ -61,7 +61,7 @@ class HtmlServiceProvider extends ServiceProvider {
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return array('html', 'form');
|
||||
return array('html', 'form', 'Collective\Html\HtmlBuilder', 'Collective\Html\FormBuilder');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use Collective\Html\FormBuilder;
|
||||
use Collective\Html\HtmlBuilder;
|
||||
use Illuminate\Routing\UrlGenerator;
|
||||
use Illuminate\Routing\RouteCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class FormBuilderTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
@@ -137,6 +138,18 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
|
||||
public function testFormRepopulationWithMixOfArraysAndObjects()
|
||||
{
|
||||
$this->formBuilder->model(['user' => (object)['password' => 'apple']]);
|
||||
$input = $this->formBuilder->text('user[password]');
|
||||
$this->assertEquals('<input name="user[password]" type="text" value="apple">', $input);
|
||||
|
||||
$this->formBuilder->model((object)['letters' => ['a', 'b', 'c']]);
|
||||
$input = $this->formBuilder->text('letters[1]');
|
||||
$this->assertEquals('<input name="letters[1]" type="text" value="b">', $input);
|
||||
}
|
||||
|
||||
|
||||
public function testFormPassword()
|
||||
{
|
||||
$form1 = $this->formBuilder->password('foo');
|
||||
@@ -171,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()
|
||||
{
|
||||
$form1 = $this->formBuilder->number('foo');
|
||||
@@ -195,6 +220,17 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase {
|
||||
$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()
|
||||
{
|
||||
@@ -279,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>');
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
@@ -356,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()
|
||||
{
|
||||
$form1 = $this->formBuilder->checkbox('foo');
|
||||
@@ -462,4 +540,4 @@ class FormBuilderModelStub {
|
||||
{
|
||||
return isset($this->data[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user