Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38f2c6ff0d | ||
|
|
b3a10245c7 | ||
|
|
623a150c91 | ||
|
|
5060a6641d | ||
|
|
41cd9291a6 | ||
|
|
818efc2e16 |
No files matched your search
+8
-8
@@ -19,16 +19,16 @@
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1.3",
|
||||
"illuminate/http": "5.7.*",
|
||||
"illuminate/routing": "5.7.*",
|
||||
"illuminate/session": "5.7.*",
|
||||
"illuminate/support": "5.7.*",
|
||||
"illuminate/view": "5.7.*"
|
||||
"illuminate/http": "5.6.*",
|
||||
"illuminate/routing": "5.6.*",
|
||||
"illuminate/session": "5.6.*",
|
||||
"illuminate/support": "5.6.*",
|
||||
"illuminate/view": "5.6.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"illuminate/database": "5.7.*",
|
||||
"illuminate/database": "5.6.*",
|
||||
"mockery/mockery": "~1.0",
|
||||
"phpunit/phpunit": "~5.4"
|
||||
"phpunit/phpunit": "~7.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -40,7 +40,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.7-dev"
|
||||
"dev-master": "5.6-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
|
||||
+17
-101
@@ -329,20 +329,6 @@ class FormBuilder
|
||||
return $this->input('password', $name, '', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a range input field.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function range($name, $value = null, $options = [])
|
||||
{
|
||||
return $this->input('range', $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a hidden input field.
|
||||
*
|
||||
@@ -478,10 +464,6 @@ class FormBuilder
|
||||
*/
|
||||
public function time($name, $value = null, $options = [])
|
||||
{
|
||||
if ($value instanceof DateTime) {
|
||||
$value = $value->format('H:i');
|
||||
}
|
||||
|
||||
return $this->input('time', $name, $value, $options);
|
||||
}
|
||||
|
||||
@@ -499,24 +481,6 @@ class FormBuilder
|
||||
return $this->input('url', $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a week input field.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function week($name, $value = null, $options = [])
|
||||
{
|
||||
if ($value instanceof DateTime) {
|
||||
$value = $value->format('Y-\WW');
|
||||
}
|
||||
|
||||
return $this->input('week', $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file input field.
|
||||
*
|
||||
@@ -805,7 +769,7 @@ class FormBuilder
|
||||
'value' => '',
|
||||
];
|
||||
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . ' hidden="hidden">' . e($display, false) . '</option>');
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display, false) . '</option>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -907,7 +871,7 @@ class FormBuilder
|
||||
return $this->getRadioCheckedState($name, $value, $checked);
|
||||
|
||||
default:
|
||||
return $this->getValueAttribute($name) === $value;
|
||||
return $this->compareValues($name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -960,7 +924,21 @@ class FormBuilder
|
||||
return $checked;
|
||||
}
|
||||
|
||||
return $this->getValueAttribute($name) === $value;
|
||||
return $this->compareValues($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the provide value loosely compares to the value assigned to the field.
|
||||
* Use loose comparison because Laravel model casting may be in affect and therefore
|
||||
* 1 == true and 0 == false.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function compareValues($name, $value)
|
||||
{
|
||||
return $this->getValueAttribute($name) == $value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1004,24 +982,6 @@ class FormBuilder
|
||||
return $this->input('image', $name, null, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a month input field.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function month($name, $value = null, $options = [])
|
||||
{
|
||||
if ($value instanceof DateTime) {
|
||||
$value = $value->format('Y-m');
|
||||
}
|
||||
|
||||
return $this->input('month', $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a color input field.
|
||||
*
|
||||
@@ -1066,50 +1026,6 @@ class FormBuilder
|
||||
return $this->toHtmlString('<button' . $this->html->attributes($options) . '>' . $value . '</button>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a datalist box field.
|
||||
*
|
||||
* @param string $id
|
||||
* @param array $list
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function datalist($id, $list = [])
|
||||
{
|
||||
$this->type = 'datalist';
|
||||
|
||||
$attributes['id'] = $id;
|
||||
|
||||
$html = [];
|
||||
|
||||
if ($this->isAssociativeArray($list)) {
|
||||
foreach ($list as $value => $display) {
|
||||
$html[] = $this->option($display, $value, null, []);
|
||||
}
|
||||
} else {
|
||||
foreach ($list as $value) {
|
||||
$html[] = $this->option($value, $value, null, []);
|
||||
}
|
||||
}
|
||||
|
||||
$attributes = $this->html->attributes($attributes);
|
||||
|
||||
$list = implode('', $html);
|
||||
|
||||
return $this->toHtmlString("<datalist{$attributes}>{$list}</datalist>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an array is associative.
|
||||
*
|
||||
* @param array $array
|
||||
* @return bool
|
||||
*/
|
||||
protected function isAssociativeArray($array)
|
||||
{
|
||||
return (array_values($array) !== $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the form action method.
|
||||
*
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ class HtmlBuilder
|
||||
{
|
||||
$defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'];
|
||||
|
||||
$attributes = array_merge($attributes, $defaults);
|
||||
$attributes = array_merge($defaults, $attributes);
|
||||
|
||||
$attributes['href'] = $this->url->asset($url, $secure);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ use Illuminate\Routing\UrlGenerator;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Mockery as m;
|
||||
|
||||
class FormAccessibleTest extends PHPUnit_Framework_TestCase
|
||||
class FormAccessibleTest extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
|
||||
+20
-69
@@ -11,7 +11,7 @@ use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Session\Store;
|
||||
use Mockery as m;
|
||||
|
||||
class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
class FormBuilderTest extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var FormBuilder
|
||||
@@ -229,17 +229,6 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('<input class="span2" name="foo" type="password" value="">', $form2);
|
||||
}
|
||||
|
||||
public function testFormRange()
|
||||
{
|
||||
$form1 = $this->formBuilder->range('foo');
|
||||
$form2 = $this->formBuilder->range('foo', 1);
|
||||
$form3 = $this->formBuilder->range('foo', null, ['class' => 'span2']);
|
||||
|
||||
$this->assertEquals('<input name="foo" type="range">', $form1);
|
||||
$this->assertEquals('<input name="foo" type="range" value="1">', $form2);
|
||||
$this->assertEquals('<input class="span2" name="foo" type="range">', $form3);
|
||||
}
|
||||
|
||||
public function testFormHidden()
|
||||
{
|
||||
$form1 = $this->formBuilder->hidden('foo');
|
||||
@@ -251,18 +240,6 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('<input class="span2" name="foo" type="hidden">', $form3);
|
||||
}
|
||||
|
||||
public function testFormMonth()
|
||||
{
|
||||
$form1 = $this->formBuilder->month('foo');
|
||||
$form2 = $this->formBuilder->month('foo', \Carbon\Carbon::now());
|
||||
$form3 = $this->formBuilder->month('foo', null, ['class' => 'span2']);
|
||||
|
||||
$this->assertEquals('<input name="foo" type="month">', $form1);
|
||||
$this->assertEquals('<input name="foo" type="month" value="' . \Carbon\Carbon::now()->format('Y-m') . '">',
|
||||
$form2);
|
||||
$this->assertEquals('<input class="span2" name="foo" type="month">', $form3);
|
||||
}
|
||||
|
||||
public function testFormSearch()
|
||||
{
|
||||
$form1 = $this->formBuilder->search('foo');
|
||||
@@ -333,29 +310,6 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('<input class="span2" name="foo" type="time">', $form3);
|
||||
}
|
||||
|
||||
public function testFormUrl()
|
||||
{
|
||||
$form1 = $this->formBuilder->url('foo');
|
||||
$form2 = $this->formBuilder->url('foo', 'http://foobar.com');
|
||||
$form3 = $this->formBuilder->url('foo', null, ['class' => 'span2']);
|
||||
|
||||
$this->assertEquals('<input name="foo" type="url">', $form1);
|
||||
$this->assertEquals('<input name="foo" type="url" value="http://foobar.com">', $form2);
|
||||
$this->assertEquals('<input class="span2" name="foo" type="url">', $form3);
|
||||
}
|
||||
|
||||
public function testFormWeek()
|
||||
{
|
||||
$form1 = $this->formBuilder->week('foo');
|
||||
$form2 = $this->formBuilder->week('foo', \Carbon\Carbon::now());
|
||||
$form3 = $this->formBuilder->week('foo', null, ['class' => 'span2']);
|
||||
|
||||
$this->assertEquals('<input name="foo" type="week">', $form1);
|
||||
$this->assertEquals('<input name="foo" type="week" value="' . \Carbon\Carbon::now()->format('Y-\WW') . '">',
|
||||
$form2);
|
||||
$this->assertEquals('<input class="span2" name="foo" type="week">', $form3);
|
||||
}
|
||||
|
||||
public function testFormFile()
|
||||
{
|
||||
$form1 = $this->formBuilder->file('foo');
|
||||
@@ -513,7 +467,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$select = $this->formBuilder->select('avc', [1 => 'Yes', 0 => 'No'], true, ['placeholder' => 'Select']);
|
||||
$this->assertEquals(
|
||||
'<select name="avc"><option value="" hidden="hidden">Select</option><option value="1" selected>Yes</option><option value="0" >No</option></select>',
|
||||
'<select name="avc"><option value="">Select</option><option value="1" selected>Yes</option><option value="0" >No</option></select>',
|
||||
$select
|
||||
);
|
||||
}
|
||||
@@ -562,7 +516,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
['placeholder' => 'Select One...']
|
||||
);
|
||||
$this->assertEquals($select,
|
||||
'<select name="size"><option selected="selected" value="" hidden="hidden">Select One...</option><option value="L">Large</option><option value="S">Small</option></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',
|
||||
@@ -571,7 +525,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
['placeholder' => 'Select One...']
|
||||
);
|
||||
$this->assertEquals($select,
|
||||
'<select name="size"><option value="" hidden="hidden">Select One...</option><option value="L" selected="selected">Large</option><option value="S">Small</option></select>');
|
||||
'<select name="size"><option value="">Select One...</option><option value="L" selected="selected">Large</option><option value="S">Small</option></select>');
|
||||
|
||||
$select = $this->formBuilder->select(
|
||||
'encoded_html',
|
||||
@@ -580,7 +534,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
['placeholder' => 'Select the ']
|
||||
);
|
||||
$this->assertEquals($select,
|
||||
'<select name="encoded_html"><option selected="selected" value="" hidden="hidden">Select the </option><option value="no_break_space"> </option><option value="ampersand">&</option><option value="lower_than"><</option></select>'
|
||||
'<select name="encoded_html"><option selected="selected" value="">Select the </option><option value="no_break_space"> </option><option value="ampersand">&</option><option value="lower_than"><</option></select>'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -704,6 +658,21 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('<input class="span2" name="foo" type="radio" value="foobar">', $form4);
|
||||
}
|
||||
|
||||
public function testFormRadioWithAttributeCastToBoolean()
|
||||
{
|
||||
$this->setModel(['itemA' => true, 'itemB' => false]);
|
||||
|
||||
$radio1 = $this->formBuilder->radio('itemA', 1);
|
||||
$radio2 = $this->formBuilder->radio('itemA', 0);
|
||||
$radio3 = $this->formBuilder->radio('itemB', 1);
|
||||
$radio4 = $this->formBuilder->radio('itemB', 0);
|
||||
|
||||
$this->assertEquals('<input checked="checked" name="itemA" type="radio" value="1">', $radio1);
|
||||
$this->assertEquals('<input name="itemA" type="radio" value="0">', $radio2);
|
||||
$this->assertEquals('<input name="itemB" type="radio" value="1">', $radio3);
|
||||
$this->assertEquals('<input checked="checked" name="itemB" type="radio" value="0">', $radio4);
|
||||
}
|
||||
|
||||
public function testFormRadioRepopulation()
|
||||
{
|
||||
$this->formBuilder->setSessionStore($session = m::mock('Illuminate\Contracts\Session\Session'));
|
||||
@@ -760,24 +729,6 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('<input class="span2" name="foo" type="color">', $form3);
|
||||
}
|
||||
|
||||
public function testDatalist()
|
||||
{
|
||||
// Associative array with string keys.
|
||||
$genders = ['M' => 'Male', 'F' => 'Female'];
|
||||
$datalist = $this->formBuilder->datalist('genders', $genders);
|
||||
$this->assertEquals('<datalist id="genders"><option value="M">Male</option><option value="F">Female</option></datalist>', $datalist);
|
||||
|
||||
// Associative array with numeric Keys
|
||||
$genders = [5 => 'Male', 6 => 'Female'];
|
||||
$datalist = $this->formBuilder->datalist('genders', $genders);
|
||||
$this->assertEquals('<datalist id="genders"><option value="5">Male</option><option value="6">Female</option></datalist>', $datalist);
|
||||
|
||||
// Not associative array.
|
||||
$genders = ['Male', 'Female'];
|
||||
$datalist = $this->formBuilder->datalist('genders', $genders);
|
||||
$this->assertEquals('<datalist id="genders"><option value="Male">Male</option><option value="Female">Female</option></datalist>', $datalist);
|
||||
}
|
||||
|
||||
public function testBooleanAttributes()
|
||||
{
|
||||
$input = $this->formBuilder->text('test', null, ['disabled']);
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Routing\RouteCollection;
|
||||
use Illuminate\Routing\UrlGenerator;
|
||||
use Mockery as m;
|
||||
|
||||
class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
||||
class HtmlBuilderTest extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user