Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04c596a699 | ||
|
|
3b177c17aa | ||
|
|
33984f5e87 | ||
|
|
b79edc7acf | ||
|
|
215f20b8c2 | ||
|
|
2c5db92f66 | ||
|
|
7e49960e8f | ||
|
|
f3b55c6033 | ||
|
|
e2fcbee917 | ||
|
|
ac46825a97 | ||
|
|
33dd7bb48e | ||
|
|
779d075f79 | ||
|
|
29253c13a3 | ||
|
|
d621ce1357 | ||
|
|
9e2a40555a | ||
|
|
8f7bc4d097 | ||
|
|
cf13e067eb | ||
|
|
b39f510897 | ||
|
|
e6bc7e5fea | ||
|
|
2f6dc39ab3 | ||
|
|
422ba2ea8d | ||
|
|
e3d9fe169d | ||
|
|
06d4296d18 | ||
|
|
97fa90bf64 | ||
|
|
79f59a016c | ||
|
|
3841eb8c89 | ||
|
|
adf0d91e2c | ||
|
|
3688b0e433 | ||
|
|
b91158bae5 | ||
|
|
471a0aa5e4 | ||
|
|
291da712f4 | ||
|
|
a47a02b962 | ||
|
|
d7aba64b44 | ||
|
|
e6471f3be1 |
No files matched your search
@@ -1,7 +1,6 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.6
|
|
||||||
- 7.0
|
- 7.0
|
||||||
- 7.1
|
- 7.1
|
||||||
|
|
||||||
|
|||||||
+24
-8
@@ -2,7 +2,7 @@
|
|||||||
"name": "laravelcollective/html",
|
"name": "laravelcollective/html",
|
||||||
"description": "HTML and Form Builders for the Laravel Framework",
|
"description": "HTML and Form Builders for the Laravel Framework",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "http://laravelcollective.com",
|
"homepage": "https://laravelcollective.com",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/LaravelCollective/html/issues",
|
"issues": "https://github.com/LaravelCollective/html/issues",
|
||||||
"source": "https://github.com/LaravelCollective/html"
|
"source": "https://github.com/LaravelCollective/html"
|
||||||
@@ -18,15 +18,15 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.6.4",
|
"php": ">=7.0.0",
|
||||||
"illuminate/http": "5.4.*",
|
"illuminate/http": "5.5.*",
|
||||||
"illuminate/routing": "5.4.*",
|
"illuminate/routing": "5.5.*",
|
||||||
"illuminate/session": "5.4.*",
|
"illuminate/session": "5.5.*",
|
||||||
"illuminate/support": "5.4.*",
|
"illuminate/support": "5.5.*",
|
||||||
"illuminate/view": "5.4.*"
|
"illuminate/view": "5.5.*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"illuminate/database": "5.4.*",
|
"illuminate/database": "5.5.*",
|
||||||
"mockery/mockery": "~0.9.4",
|
"mockery/mockery": "~0.9.4",
|
||||||
"phpunit/phpunit": "~5.4"
|
"phpunit/phpunit": "~5.4"
|
||||||
},
|
},
|
||||||
@@ -37,5 +37,21 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"src/helpers.php"
|
"src/helpers.php"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "5.5-dev"
|
||||||
|
},
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Collective\\Html\\HtmlServiceProvider"
|
||||||
|
],
|
||||||
|
"aliases": {
|
||||||
|
"Form": "Collective\\Html\\FormFacade",
|
||||||
|
"Html": "Collective\\Html\\HtmlFacade"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true
|
||||||
|
}
|
||||||
@@ -87,7 +87,7 @@ trait FormAccessible
|
|||||||
|
|
||||||
$mutator = collect($methods)
|
$mutator = collect($methods)
|
||||||
->first(function (ReflectionMethod $method) use ($key) {
|
->first(function (ReflectionMethod $method) use ($key) {
|
||||||
return $method->getName() == 'form' . Str::studly($key) . 'Attribute';
|
return $method->getName() === 'form' . Str::studly($key) . 'Attribute';
|
||||||
});
|
});
|
||||||
|
|
||||||
return (bool) $mutator;
|
return (bool) $mutator;
|
||||||
|
|||||||
+45
-21
@@ -191,6 +191,16 @@ class FormBuilder
|
|||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current model instance on the form builder.
|
||||||
|
*
|
||||||
|
* @return mixed $model
|
||||||
|
*/
|
||||||
|
public function getModel()
|
||||||
|
{
|
||||||
|
return $this->model;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the current form.
|
* Close the current form.
|
||||||
*
|
*
|
||||||
@@ -562,9 +572,10 @@ class FormBuilder
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array $list
|
* @param array $list
|
||||||
* @param string $selected
|
* @param string|bool $selected
|
||||||
* @param array $selectAttributes
|
* @param array $selectAttributes
|
||||||
* @param array $optionsAttributes
|
* @param array $optionsAttributes
|
||||||
|
* @param array $optgroupsAttributes
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Support\HtmlString
|
* @return \Illuminate\Support\HtmlString
|
||||||
*/
|
*/
|
||||||
@@ -573,7 +584,8 @@ class FormBuilder
|
|||||||
$list = [],
|
$list = [],
|
||||||
$selected = null,
|
$selected = null,
|
||||||
array $selectAttributes = [],
|
array $selectAttributes = [],
|
||||||
array $optionsAttributes = []
|
array $optionsAttributes = [],
|
||||||
|
array $optgroupsAttributes = []
|
||||||
) {
|
) {
|
||||||
$this->type = 'select';
|
$this->type = 'select';
|
||||||
|
|
||||||
@@ -599,8 +611,9 @@ class FormBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($list as $value => $display) {
|
foreach ($list as $value => $display) {
|
||||||
$optionAttributes = isset($optionsAttributes[$value]) ? $optionsAttributes[$value] : [];
|
$optionAttributes = $optionsAttributes[$value] ?? [];
|
||||||
$html[] = $this->getSelectOption($display, $value, $selected, $optionAttributes);
|
$optgroupAttributes = $optgroupsAttributes[$value] ?? [];
|
||||||
|
$html[] = $this->getSelectOption($display, $value, $selected, $optionAttributes, $optgroupAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Once we have all of this HTML, we can join this into a single element after
|
// Once we have all of this HTML, we can join this into a single element after
|
||||||
@@ -675,13 +688,14 @@ class FormBuilder
|
|||||||
* @param string $value
|
* @param string $value
|
||||||
* @param string $selected
|
* @param string $selected
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
|
* @param array $optgroupAttributes
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Support\HtmlString
|
* @return \Illuminate\Support\HtmlString
|
||||||
*/
|
*/
|
||||||
public function getSelectOption($display, $value, $selected, array $attributes = [])
|
public function getSelectOption($display, $value, $selected, array $attributes = [], array $optgroupAttributes = [])
|
||||||
{
|
{
|
||||||
if (is_array($display)) {
|
if (is_array($display)) {
|
||||||
return $this->optionGroup($display, $value, $selected, $attributes);
|
return $this->optionGroup($display, $value, $selected, $optgroupAttributes, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->option($display, $value, $selected, $attributes);
|
return $this->option($display, $value, $selected, $attributes);
|
||||||
@@ -694,18 +708,21 @@ class FormBuilder
|
|||||||
* @param string $label
|
* @param string $label
|
||||||
* @param string $selected
|
* @param string $selected
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
|
* @param array $optionsAttributes
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Support\HtmlString
|
* @return \Illuminate\Support\HtmlString
|
||||||
*/
|
*/
|
||||||
protected function optionGroup($list, $label, $selected, array $attributes = [])
|
protected function optionGroup($list, $label, $selected, array $attributes = [], array $optionsAttributes = [])
|
||||||
{
|
{
|
||||||
$html = [];
|
$html = [];
|
||||||
|
|
||||||
foreach ($list as $value => $display) {
|
foreach ($list as $value => $display) {
|
||||||
$html[] = $this->option($display, $value, $selected, $attributes);
|
$optionAttributes = $optionsAttributes[$value] ?? [];
|
||||||
|
|
||||||
|
$html[] = $this->option($display, $value, $selected, $optionAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->toHtmlString('<optgroup label="' . e($label) . '">' . implode('', $html) . '</optgroup>');
|
return $this->toHtmlString('<optgroup label="' . e($label) . '"' . $this->html->attributes($attributes) . '>' . implode('', $html) . '</optgroup>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -722,9 +739,14 @@ class FormBuilder
|
|||||||
{
|
{
|
||||||
$selected = $this->getSelectedValue($value, $selected);
|
$selected = $this->getSelectedValue($value, $selected);
|
||||||
|
|
||||||
$options = ['value' => $value, 'selected' => $selected] + $attributes;
|
$options = array_merge(['value' => $value, 'selected' => $selected], $attributes);
|
||||||
|
|
||||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display) . '</option>');
|
$string = '<option' . $this->html->attributes($options) . '>';
|
||||||
|
if ($display !== null) {
|
||||||
|
$string .= e($display) . '</option>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->toHtmlString($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -762,8 +784,10 @@ class FormBuilder
|
|||||||
} elseif ($selected instanceof Collection) {
|
} elseif ($selected instanceof Collection) {
|
||||||
return $selected->contains($value) ? 'selected' : null;
|
return $selected->contains($value) ? 'selected' : null;
|
||||||
}
|
}
|
||||||
|
if (is_int($value) && is_bool($selected)) {
|
||||||
return ((string) $value == (string) $selected) ? 'selected' : null;
|
return (bool)$value === $selected;
|
||||||
|
}
|
||||||
|
return ((string) $value === (string) $selected) ? 'selected' : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -844,7 +868,7 @@ class FormBuilder
|
|||||||
return $this->getRadioCheckedState($name, $value, $checked);
|
return $this->getRadioCheckedState($name, $value, $checked);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $this->getValueAttribute($name) == $value;
|
return $this->getValueAttribute($name) === $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -865,7 +889,7 @@ class FormBuilder
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->missingOldAndModel($name) && !$request) {
|
if ($this->missingOldAndModel($name) && is_null($request)) {
|
||||||
return $checked;
|
return $checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -897,7 +921,7 @@ class FormBuilder
|
|||||||
return $checked;
|
return $checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getValueAttribute($name) == $value;
|
return $this->getValueAttribute($name) === $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -996,7 +1020,7 @@ class FormBuilder
|
|||||||
{
|
{
|
||||||
$method = strtoupper($method);
|
$method = strtoupper($method);
|
||||||
|
|
||||||
return $method != 'GET' ? 'POST' : $method;
|
return $method !== 'GET' ? 'POST' : $method;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1098,7 +1122,7 @@ class FormBuilder
|
|||||||
// If the method is something other than GET we will go ahead and attach the
|
// If the method is something other than GET we will go ahead and attach the
|
||||||
// CSRF token to the form, as this can't hurt and is convenient to simply
|
// CSRF token to the form, as this can't hurt and is convenient to simply
|
||||||
// always have available on every form the developers creates for them.
|
// always have available on every form the developers creates for them.
|
||||||
if ($method != 'GET') {
|
if ($method !== 'GET') {
|
||||||
$appendage .= $this->token();
|
$appendage .= $this->token();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1140,7 +1164,7 @@ class FormBuilder
|
|||||||
|
|
||||||
$old = $this->old($name);
|
$old = $this->old($name);
|
||||||
|
|
||||||
if (! is_null($old) && $name != '_method') {
|
if (! is_null($old) && $name !== '_method') {
|
||||||
return $old;
|
return $old;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1159,7 +1183,7 @@ class FormBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
$request = $this->request($name);
|
$request = $this->request($name);
|
||||||
if (!is_null($request)) {
|
if (! is_null($request) && $name !== '_method') {
|
||||||
return $request;
|
return $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1243,7 +1267,7 @@ class FormBuilder
|
|||||||
*/
|
*/
|
||||||
public function oldInputIsEmpty()
|
public function oldInputIsEmpty()
|
||||||
{
|
{
|
||||||
return (isset($this->session) && count($this->session->getOldInput()) == 0);
|
return (isset($this->session) && count($this->session->getOldInput()) === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+11
-11
@@ -78,7 +78,7 @@ class HtmlBuilder
|
|||||||
{
|
{
|
||||||
$attributes['src'] = $this->url->asset($url, $secure);
|
$attributes['src'] = $this->url->asset($url, $secure);
|
||||||
|
|
||||||
return $this->toHtmlString('<script' . $this->attributes($attributes) . '></script>' . PHP_EOL);
|
return $this->toHtmlString('<script' . $this->attributes($attributes) . '></script>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,11 +94,11 @@ class HtmlBuilder
|
|||||||
{
|
{
|
||||||
$defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'];
|
$defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'];
|
||||||
|
|
||||||
$attributes = $attributes + $defaults;
|
$attributes = array_merge($attributes, $defaults);
|
||||||
|
|
||||||
$attributes['href'] = $this->url->asset($url, $secure);
|
$attributes['href'] = $this->url->asset($url, $secure);
|
||||||
|
|
||||||
return $this->toHtmlString('<link' . $this->attributes($attributes) . '>' . PHP_EOL);
|
return $this->toHtmlString('<link' . $this->attributes($attributes) . '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,11 +132,11 @@ class HtmlBuilder
|
|||||||
{
|
{
|
||||||
$defaults = ['rel' => 'shortcut icon', 'type' => 'image/x-icon'];
|
$defaults = ['rel' => 'shortcut icon', 'type' => 'image/x-icon'];
|
||||||
|
|
||||||
$attributes = $attributes + $defaults;
|
$attributes = array_merge($attributes, $defaults);
|
||||||
|
|
||||||
$attributes['href'] = $this->url->asset($url, $secure);
|
$attributes['href'] = $this->url->asset($url, $secure);
|
||||||
|
|
||||||
return $this->toHtmlString('<link' . $this->attributes($attributes) . '>' . PHP_EOL);
|
return $this->toHtmlString('<link' . $this->attributes($attributes) . '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,7 +162,7 @@ class HtmlBuilder
|
|||||||
$title = $this->entities($title);
|
$title = $this->entities($title);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->toHtmlString('<a href="' . $url . '"' . $this->attributes($attributes) . '>' . $title . '</a>');
|
return $this->toHtmlString('<a href="' . $this->entities($url) . '"' . $this->attributes($attributes) . '>' . $title . '</a>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -357,7 +357,7 @@ class HtmlBuilder
|
|||||||
{
|
{
|
||||||
$html = '';
|
$html = '';
|
||||||
|
|
||||||
if (count($list) == 0) {
|
if (count($list) === 0) {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +451,7 @@ class HtmlBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Treat boolean attributes as HTML properties
|
// Treat boolean attributes as HTML properties
|
||||||
if (is_bool($value) && $key != 'value') {
|
if (is_bool($value) && $key !== 'value') {
|
||||||
return $value ? $key : '';
|
return $value ? $key : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,7 +511,7 @@ class HtmlBuilder
|
|||||||
|
|
||||||
$attributes = array_merge($defaults, $attributes);
|
$attributes = array_merge($defaults, $attributes);
|
||||||
|
|
||||||
return $this->toHtmlString('<meta' . $this->attributes($attributes) . '>' . PHP_EOL);
|
return $this->toHtmlString('<meta' . $this->attributes($attributes) . '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -525,8 +525,8 @@ class HtmlBuilder
|
|||||||
*/
|
*/
|
||||||
public function tag($tag, $content, array $attributes = [])
|
public function tag($tag, $content, array $attributes = [])
|
||||||
{
|
{
|
||||||
$content = is_array($content) ? implode(PHP_EOL, $content) : $content;
|
$content = is_array($content) ? implode('', $content) : $content;
|
||||||
return $this->toHtmlString('<' . $tag . $this->attributes($attributes) . '>' . PHP_EOL . $this->toHtmlString($content) . PHP_EOL . '</' . $tag . '>' . PHP_EOL);
|
return $this->toHtmlString('<' . $tag . $this->attributes($attributes) . '>' . $this->toHtmlString($content) . '</' . $tag . '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -402,6 +402,37 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
'<select class="class-name" id="select-id" name="size"><optgroup label="Large sizes"><option value="L">Large</option><option value="XL">Extra Large</option></optgroup><option value="S">Small</option></select>'
|
'<select class="class-name" id="select-id" name="size"><optgroup label="Large sizes"><option value="L">Large</option><option value="XL">Extra Large</option></optgroup><option value="S">Small</option></select>'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$select = $this->formBuilder->select(
|
||||||
|
'size',
|
||||||
|
[
|
||||||
|
'Large sizes' => [
|
||||||
|
'L' => 'Large',
|
||||||
|
'XL' => 'Extra Large',
|
||||||
|
],
|
||||||
|
'M' => 'Medium',
|
||||||
|
'Small sizes' => [
|
||||||
|
'S' => 'Small',
|
||||||
|
'XS' => 'Extra Small',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
'Large sizes' => [
|
||||||
|
'L' => ['disabled']
|
||||||
|
],
|
||||||
|
'M' => ['disabled'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'Small sizes' => ['disabled'],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
$select,
|
||||||
|
'<select name="size"><optgroup label="Large sizes"><option value="L" disabled>Large</option><option value="XL">Extra Large</option></optgroup><option value="M" disabled>Medium</option><optgroup label="Small sizes" disabled><option value="S">Small</option><option value="XS">Extra Small</option></optgroup></select>'
|
||||||
|
);
|
||||||
|
|
||||||
$select = $this->formBuilder->select(
|
$select = $this->formBuilder->select(
|
||||||
'encoded_html',
|
'encoded_html',
|
||||||
['no_break_space' => ' ', 'ampersand' => '&', 'lower_than' => '<'],
|
['no_break_space' => ' ', 'ampersand' => '&', 'lower_than' => '<'],
|
||||||
@@ -433,6 +464,12 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
'<select name="countries"><option value="1" selected="selected">L</option><option value="2">M</option></select>',
|
'<select name="countries"><option value="1" selected="selected">L</option><option value="2">M</option></select>',
|
||||||
$result
|
$result
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$select = $this->formBuilder->select('avc', [1 => 'Yes', 0 => 'No'], true, ['placeholder' => 'Select']);
|
||||||
|
$this->assertEquals(
|
||||||
|
'<select name="avc"><option value="">Select</option><option value="1" selected>Yes</option><option value="0" >No</option></select>',
|
||||||
|
$select
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSelectCollection()
|
public function testSelectCollection()
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$result = $this->htmlBuilder->meta('description', 'Lorem ipsum dolor sit amet.');
|
$result = $this->htmlBuilder->meta('description', 'Lorem ipsum dolor sit amet.');
|
||||||
|
|
||||||
$this->assertEquals('<meta name="description" content="Lorem ipsum dolor sit amet.">' . PHP_EOL, $result);
|
$this->assertEquals('<meta name="description" content="Lorem ipsum dolor sit amet.">', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTag()
|
public function testTag()
|
||||||
@@ -83,17 +83,17 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$result4 = $this->htmlBuilder->tag('div', $content, ['class' => 'row']);
|
$result4 = $this->htmlBuilder->tag('div', $content, ['class' => 'row']);
|
||||||
|
|
||||||
$this->assertEquals('<p>' . PHP_EOL . 'Lorem ipsum dolor sit amet.' . PHP_EOL . '</p>' . PHP_EOL, $result1);
|
$this->assertEquals('<p>Lorem ipsum dolor sit amet.</p>', $result1);
|
||||||
$this->assertEquals('<p class="text-center">' . PHP_EOL . 'Lorem ipsum dolor sit amet.' . PHP_EOL . '</p>' . PHP_EOL, $result2);
|
$this->assertEquals('<p class="text-center">Lorem ipsum dolor sit amet.</p>', $result2);
|
||||||
$this->assertEquals('<div class="row">' . PHP_EOL . '<p>Lorem ipsum dolor sit amet.</p>' . PHP_EOL . '</div>' . PHP_EOL, $result3);
|
$this->assertEquals('<div class="row"><p>Lorem ipsum dolor sit amet.</p></div>', $result3);
|
||||||
$this->assertEquals('<div class="row">' . PHP_EOL . '<img src="http://example.com/image1">' . PHP_EOL . '<img src="http://example.com/image2">' . PHP_EOL . '</div>' . PHP_EOL, $result4);
|
$this->assertEquals('<div class="row"><img src="http://example.com/image1"><img src="http://example.com/image2"></div>', $result4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMetaOpenGraph()
|
public function testMetaOpenGraph()
|
||||||
{
|
{
|
||||||
$result = $this->htmlBuilder->meta(null, 'website', ['property' => 'og:type']);
|
$result = $this->htmlBuilder->meta(null, 'website', ['property' => 'og:type']);
|
||||||
|
|
||||||
$this->assertEquals('<meta content="website" property="og:type">' . PHP_EOL, $result);
|
$this->assertEquals('<meta content="website" property="og:type">', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFavicon()
|
public function testFavicon()
|
||||||
@@ -102,7 +102,7 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
$target = $this->urlGenerator->to('bar.ico');
|
$target = $this->urlGenerator->to('bar.ico');
|
||||||
$result = $this->htmlBuilder->favicon('http://foo.com/bar.ico');
|
$result = $this->htmlBuilder->favicon('http://foo.com/bar.ico');
|
||||||
|
|
||||||
$this->assertEquals('<link rel="shortcut icon" type="image/x-icon" href="' . $target . '">' . PHP_EOL, $result);
|
$this->assertEquals('<link rel="shortcut icon" type="image/x-icon" href="' . $target . '">', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testComponentRegistration()
|
public function testComponentRegistration()
|
||||||
@@ -118,8 +118,11 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$result2 = $this->htmlBuilder->link("http://www.example.com", "<span>Example.com</span>", ["class" => "example-link"], null, false);
|
$result2 = $this->htmlBuilder->link("http://www.example.com", "<span>Example.com</span>", ["class" => "example-link"], null, false);
|
||||||
|
|
||||||
|
$result3 = $this->htmlBuilder->link("https://a.com/b?id=4¬_id=5", "URL which needs escaping");
|
||||||
|
|
||||||
$this->assertEquals('<a href="http://www.example.com" class="example-link"><span>Example.com</span></a>', $result1);
|
$this->assertEquals('<a href="http://www.example.com" class="example-link"><span>Example.com</span></a>', $result1);
|
||||||
$this->assertEquals('<a href="http://www.example.com" class="example-link"><span>Example.com</span></a>', $result2);
|
$this->assertEquals('<a href="http://www.example.com" class="example-link"><span>Example.com</span></a>', $result2);
|
||||||
|
$this->assertEquals('<a href="https://a.com/b?id=4&not_id=5">URL which needs escaping</a>', $result3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMailto()
|
public function testMailto()
|
||||||
|
|||||||
Reference in new issue
Block a user