Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
961ce141c1 | ||
|
|
c4c87916c3 | ||
|
|
abec449ed8 | ||
|
|
eb132aed5c | ||
|
|
9f534cb45b | ||
|
|
71b81b7f96 | ||
|
|
bcf0697d7d | ||
|
|
d79805ade4 | ||
|
|
24ee0aadc0 | ||
|
|
0fc25932db | ||
|
|
92a4833e11 | ||
|
|
f6d9a66624 | ||
|
|
0d1d1fcd5a | ||
|
|
f9a4e185f4 | ||
|
|
4d5ed8a59a | ||
|
|
0625f71fd9 | ||
|
|
a3d42da280 | ||
|
|
d65deb4e77 | ||
|
|
02c75dff24 | ||
|
|
9dc27a4188 | ||
|
|
df8acc24bb | ||
|
|
3a312d39ff | ||
|
|
fa2628d311 | ||
|
|
e5011d337c | ||
|
|
0e8e2dbc67 | ||
|
|
7ec0ca55ca | ||
|
|
6f35784c8b | ||
|
|
c88b2d59a5 | ||
|
|
add2c74b14 | ||
|
|
10111f558c | ||
|
|
b60bb4da7c | ||
|
|
e7db3dd11a |
No files matched your search
+2
-1
@@ -1,8 +1,9 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.5
|
|
||||||
- 5.6
|
- 5.6
|
||||||
|
- 7.0
|
||||||
|
- 7.1
|
||||||
- hhvm
|
- hhvm
|
||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|||||||
+9
-9
@@ -18,17 +18,17 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.5.9",
|
"php": ">=5.6.4",
|
||||||
"illuminate/http": "5.2.*",
|
"illuminate/http": "5.3.*",
|
||||||
"illuminate/routing": "5.2.*",
|
"illuminate/routing": "5.3.*",
|
||||||
"illuminate/session": "5.2.*",
|
"illuminate/session": "5.3.*",
|
||||||
"illuminate/support": "5.2.*",
|
"illuminate/support": "5.3.*",
|
||||||
"illuminate/view": "5.2.*"
|
"illuminate/view": "5.3.*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"illuminate/database": "5.2.*",
|
"illuminate/database": "5.3.*",
|
||||||
"mockery/mockery": "~0.9",
|
"mockery/mockery": "~0.9.4",
|
||||||
"phpunit/phpunit": "~4.0"
|
"phpunit/phpunit": "~5.4"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ trait Componentable
|
|||||||
$default = null;
|
$default = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[$variable] = array_get($arguments, $i) ?: $default;
|
$data[$variable] = array_get($arguments, $i, $default);
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@@ -107,5 +107,4 @@ trait Componentable
|
|||||||
|
|
||||||
throw new BadMethodCallException("Method {$method} does not exist.");
|
throw new BadMethodCallException("Method {$method} does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,8 @@ trait FormAccessible
|
|||||||
return $this->mutateFormAttribute($key, $value);
|
return $this->mutateFormAttribute($key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
// No form mutator, let the model resolve this
|
||||||
|
return data_get($this, $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +55,7 @@ trait FormAccessible
|
|||||||
$methods = $this->getReflection()->getMethods(ReflectionMethod::IS_PUBLIC);
|
$methods = $this->getReflection()->getMethods(ReflectionMethod::IS_PUBLIC);
|
||||||
|
|
||||||
$mutator = collect($methods)
|
$mutator = collect($methods)
|
||||||
->first(function ($index, 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';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Executable → Regular
+9
-6
@@ -7,14 +7,12 @@ use BadMethodCallException;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Session\SessionInterface;
|
use Illuminate\Session\SessionInterface;
|
||||||
use Illuminate\Support\Traits\Macroable;
|
use Illuminate\Support\Traits\Macroable;
|
||||||
use Illuminate\Contracts\Routing\UrlGenerator;
|
use Illuminate\Contracts\Routing\UrlGenerator;
|
||||||
|
|
||||||
class FormBuilder
|
class FormBuilder
|
||||||
{
|
{
|
||||||
|
|
||||||
use Macroable, Componentable {
|
use Macroable, Componentable {
|
||||||
Macroable::__call as macroCall;
|
Macroable::__call as macroCall;
|
||||||
Componentable::__call as componentCall;
|
Componentable::__call as componentCall;
|
||||||
@@ -211,16 +209,21 @@ class FormBuilder
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param array $options
|
* @param array $options
|
||||||
|
* @param bool $escape_html
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Support\HtmlString
|
* @return \Illuminate\Support\HtmlString
|
||||||
*/
|
*/
|
||||||
public function label($name, $value = null, $options = [])
|
public function label($name, $value = null, $options = [], $escape_html = true)
|
||||||
{
|
{
|
||||||
$this->labels[] = $name;
|
$this->labels[] = $name;
|
||||||
|
|
||||||
$options = $this->html->attributes($options);
|
$options = $this->html->attributes($options);
|
||||||
|
|
||||||
$value = e($this->formatLabel($name, $value));
|
$value = $this->formatLabel($name, $value);
|
||||||
|
|
||||||
|
if ($escape_html) {
|
||||||
|
$value = $this->html->entities($value);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->toHtmlString('<label for="' . $name . '"' . $options . '>' . $value . '</label>');
|
return $this->toHtmlString('<label for="' . $name . '"' . $options . '>' . $value . '</label>');
|
||||||
}
|
}
|
||||||
@@ -1081,7 +1084,7 @@ class FormBuilder
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! is_null($this->old($name))) {
|
if (! is_null($this->old($name)) && $name != '_method') {
|
||||||
return $this->old($name);
|
return $this->old($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1104,7 +1107,7 @@ class FormBuilder
|
|||||||
protected function getModelValueAttribute($name)
|
protected function getModelValueAttribute($name)
|
||||||
{
|
{
|
||||||
if (method_exists($this->model, 'getFormValue')) {
|
if (method_exists($this->model, 'getFormValue')) {
|
||||||
return $this->model->getFormValue($name);
|
return $this->model->getFormValue($this->transformKey($name));
|
||||||
}
|
}
|
||||||
|
|
||||||
return data_get($this->model, $this->transformKey($name));
|
return data_get($this->model, $this->transformKey($name));
|
||||||
|
|||||||
+41
-5
@@ -10,7 +10,6 @@ use Illuminate\Contracts\Routing\UrlGenerator;
|
|||||||
|
|
||||||
class HtmlBuilder
|
class HtmlBuilder
|
||||||
{
|
{
|
||||||
|
|
||||||
use Macroable, Componentable {
|
use Macroable, Componentable {
|
||||||
Macroable::__call as macroCall;
|
Macroable::__call as macroCall;
|
||||||
Componentable::__call as componentCall;
|
Componentable::__call as componentCall;
|
||||||
@@ -147,10 +146,11 @@ class HtmlBuilder
|
|||||||
* @param string $title
|
* @param string $title
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
* @param bool $secure
|
* @param bool $secure
|
||||||
|
* @param bool $escape
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Support\HtmlString
|
* @return \Illuminate\Support\HtmlString
|
||||||
*/
|
*/
|
||||||
public function link($url, $title = null, $attributes = [], $secure = null)
|
public function link($url, $title = null, $attributes = [], $secure = null, $escape = true)
|
||||||
{
|
{
|
||||||
$url = $this->url->to($url, [], $secure);
|
$url = $this->url->to($url, [], $secure);
|
||||||
|
|
||||||
@@ -158,7 +158,11 @@ class HtmlBuilder
|
|||||||
$title = $url;
|
$title = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->toHtmlString('<a href="' . $url . '"' . $this->attributes($attributes) . '>' . $this->entities($title) . '</a>');
|
if ($escape) {
|
||||||
|
$title = $this->entities($title);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->toHtmlString('<a href="' . $url . '"' . $this->attributes($attributes) . '>' . $title . '</a>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,18 +246,23 @@ class HtmlBuilder
|
|||||||
* @param string $email
|
* @param string $email
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
|
* @param bool $escape
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Support\HtmlString
|
* @return \Illuminate\Support\HtmlString
|
||||||
*/
|
*/
|
||||||
public function mailto($email, $title = null, $attributes = [])
|
public function mailto($email, $title = null, $attributes = [], $escape = true)
|
||||||
{
|
{
|
||||||
$email = $this->email($email);
|
$email = $this->email($email);
|
||||||
|
|
||||||
$title = $title ?: $email;
|
$title = $title ?: $email;
|
||||||
|
|
||||||
|
if ($escape) {
|
||||||
|
$title = $this->entities($title);
|
||||||
|
}
|
||||||
|
|
||||||
$email = $this->obfuscate('mailto:') . $email;
|
$email = $this->obfuscate('mailto:') . $email;
|
||||||
|
|
||||||
return $this->toHtmlString('<a href="' . $email . '"' . $this->attributes($attributes) . '>' . $this->entities($title) . '</a>');
|
return $this->toHtmlString('<a href="' . $email . '"' . $this->attributes($attributes) . '>' . $title . '</a>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,6 +277,18 @@ class HtmlBuilder
|
|||||||
return str_replace('@', '@', $this->obfuscate($email));
|
return str_replace('@', '@', $this->obfuscate($email));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates non-breaking space entities based on number supplied.
|
||||||
|
*
|
||||||
|
* @param int $num
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function nbsp($num = 1)
|
||||||
|
{
|
||||||
|
return str_repeat(' ', $num);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an ordered list of items.
|
* Generate an ordered list of items.
|
||||||
*
|
*
|
||||||
@@ -486,6 +507,21 @@ class HtmlBuilder
|
|||||||
return $this->toHtmlString('<meta' . $this->attributes($attributes) . '>' . PHP_EOL);
|
return $this->toHtmlString('<meta' . $this->attributes($attributes) . '>' . PHP_EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate an html tag.
|
||||||
|
*
|
||||||
|
* @param string $tag
|
||||||
|
* @param mixed $content
|
||||||
|
* @param array $attributes
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Support\HtmlString
|
||||||
|
*/
|
||||||
|
public function tag($tag, $content, array $attributes = [])
|
||||||
|
{
|
||||||
|
$content = is_array($content) ? implode(PHP_EOL, $content) : $content;
|
||||||
|
return $this->toHtmlString('<' . $tag . $this->attributes($attributes) . '>' . PHP_EOL . $this->toHtmlString($content) . PHP_EOL . '</' . $tag . '>' . PHP_EOL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform the string to an Html serializable object
|
* Transform the string to an Html serializable object
|
||||||
*
|
*
|
||||||
|
|||||||
+3
-2
@@ -8,12 +8,13 @@ if (! function_exists('link_to')) {
|
|||||||
* @param string $title
|
* @param string $title
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
* @param bool $secure
|
* @param bool $secure
|
||||||
|
* @param bool $escape
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function link_to($url, $title = null, $attributes = [], $secure = null)
|
function link_to($url, $title = null, $attributes = [], $secure = null, $escape = true)
|
||||||
{
|
{
|
||||||
return app('html')->link($url, $title, $attributes, $secure);
|
return app('html')->link($url, $title, $attributes, $secure, $escape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ use Mockery as m;
|
|||||||
|
|
||||||
class FormAccessibleTest extends PHPUnit_Framework_TestCase
|
class FormAccessibleTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
Capsule::table('models')->truncate();
|
Capsule::table('models')->truncate();
|
||||||
@@ -25,6 +24,9 @@ class FormAccessibleTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->modelData = [
|
$this->modelData = [
|
||||||
'string' => 'abcdefghijklmnop',
|
'string' => 'abcdefghijklmnop',
|
||||||
'email' => 'tj@tjshafer.com',
|
'email' => 'tj@tjshafer.com',
|
||||||
|
'address' => [
|
||||||
|
'street' => 'abcde st'
|
||||||
|
],
|
||||||
'created_at' => $this->now,
|
'created_at' => $this->now,
|
||||||
'updated_at' => $this->now,
|
'updated_at' => $this->now,
|
||||||
];
|
];
|
||||||
@@ -44,6 +46,12 @@ class FormAccessibleTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($model->getFormValue('created_at'), $this->now->timestamp);
|
$this->assertEquals($model->getFormValue('created_at'), $this->now->timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItCanGetRelatedValueForForms()
|
||||||
|
{
|
||||||
|
$model = new ModelThatUsesForms($this->modelData);
|
||||||
|
$this->assertEquals($model->getFormValue('address.street'), 'abcde st');
|
||||||
|
}
|
||||||
|
|
||||||
public function testItCanStillMutateValuesForViews()
|
public function testItCanStillMutateValuesForViews()
|
||||||
{
|
{
|
||||||
$model = new ModelThatUsesForms($this->modelData);
|
$model = new ModelThatUsesForms($this->modelData);
|
||||||
@@ -65,7 +73,6 @@ class FormAccessibleTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
class ModelThatUsesForms extends Model
|
class ModelThatUsesForms extends Model
|
||||||
{
|
{
|
||||||
|
|
||||||
use FormAccessible;
|
use FormAccessible;
|
||||||
|
|
||||||
protected $table = 'models';
|
protected $table = 'models';
|
||||||
@@ -93,7 +100,6 @@ class ModelThatUsesForms extends Model
|
|||||||
|
|
||||||
class ModelThatDoesntUseForms extends Model
|
class ModelThatDoesntUseForms extends Model
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $table = 'models';
|
protected $table = 'models';
|
||||||
|
|
||||||
public function getStringAttribute($value)
|
public function getStringAttribute($value)
|
||||||
|
|||||||
@@ -58,9 +58,11 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$form1 = $this->formBuilder->label('foo', 'Foobar');
|
$form1 = $this->formBuilder->label('foo', 'Foobar');
|
||||||
$form2 = $this->formBuilder->label('foo', 'Foobar', ['class' => 'control-label']);
|
$form2 = $this->formBuilder->label('foo', 'Foobar', ['class' => 'control-label']);
|
||||||
|
$form3 = $this->formBuilder->label('foo', 'Foobar <i>bar</i>', null, false);
|
||||||
|
|
||||||
$this->assertEquals('<label for="foo">Foobar</label>', $form1);
|
$this->assertEquals('<label for="foo">Foobar</label>', $form1);
|
||||||
$this->assertEquals('<label for="foo" class="control-label">Foobar</label>', $form2);
|
$this->assertEquals('<label for="foo" class="control-label">Foobar</label>', $form2);
|
||||||
|
$this->assertEquals('<label for="foo">Foobar <i>bar</i></label>', $form3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormInput()
|
public function testFormInput()
|
||||||
@@ -278,6 +280,27 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
['name' => 'select-name']
|
['name' => 'select-name']
|
||||||
);
|
);
|
||||||
$this->assertEquals($select, '<select name="select-name" id="select-name-id"></select>');
|
$this->assertEquals($select, '<select name="select-name" id="select-name-id"></select>');
|
||||||
|
|
||||||
|
$select = $this->formBuilder->select(
|
||||||
|
'size',
|
||||||
|
[
|
||||||
|
'Large sizes' => [
|
||||||
|
'L' => 'Large',
|
||||||
|
'XL' => 'Extra Large',
|
||||||
|
],
|
||||||
|
'S' => 'Small',
|
||||||
|
],
|
||||||
|
null,
|
||||||
|
[
|
||||||
|
'class' => 'class-name',
|
||||||
|
'id' => 'select-id',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
$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>'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormSelectRepopulation()
|
public function testFormSelectRepopulation()
|
||||||
@@ -511,7 +534,6 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
class FormBuilderModelStub
|
class FormBuilderModelStub
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $data;
|
protected $data;
|
||||||
|
|
||||||
public function __construct(array $data = [])
|
public function __construct(array $data = [])
|
||||||
|
|||||||
@@ -46,6 +46,27 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
$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.">' . PHP_EOL, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testTag()
|
||||||
|
{
|
||||||
|
$result1 = $this->htmlBuilder->tag('p', 'Lorem ipsum dolor sit amet.');
|
||||||
|
|
||||||
|
$result2 = $this->htmlBuilder->tag('p', 'Lorem ipsum dolor sit amet.', ['class' => 'text-center']);
|
||||||
|
|
||||||
|
$result3 = $this->htmlBuilder->tag('div', '<p>Lorem ipsum dolor sit amet.</p>', ['class' => 'row']);
|
||||||
|
|
||||||
|
$content = [
|
||||||
|
$this->htmlBuilder->image('http://example.com/image1'),
|
||||||
|
$this->htmlBuilder->image('http://example.com/image2'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$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 class="text-center">' . PHP_EOL . 'Lorem ipsum dolor sit amet.' . PHP_EOL . '</p>' . PHP_EOL, $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">' . PHP_EOL . '<img src="http://example.com/image1">' . PHP_EOL . '<img src="http://example.com/image2">' . PHP_EOL . '</div>' . PHP_EOL, $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']);
|
||||||
@@ -68,4 +89,30 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertTrue($this->htmlBuilder->hasComponent('tweet'));
|
$this->assertTrue($this->htmlBuilder->hasComponent('tweet'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLink()
|
||||||
|
{
|
||||||
|
$result1 = $this->htmlBuilder->link("http://www.example.com", "<span>Example.com</span>", ["class" => "example-link"], null, true);
|
||||||
|
|
||||||
|
$result2 = $this->htmlBuilder->link("http://www.example.com", "<span>Example.com</span>", ["class" => "example-link"], null, false);
|
||||||
|
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMailto()
|
||||||
|
{
|
||||||
|
$htmlBuilder = m::mock('Collective\Html\HtmlBuilder[obfuscate,email]', [$this->urlGenerator, $this->viewFactory]);
|
||||||
|
$htmlBuilder->shouldReceive('obfuscate', 'email')->andReturnUsing(function () {
|
||||||
|
$args = func_get_args();
|
||||||
|
return $args[0];
|
||||||
|
});
|
||||||
|
|
||||||
|
$result1 = $htmlBuilder->mailto("person@example.com", "<span>First Name Last</span>", ["class" => "example-link"], true);
|
||||||
|
|
||||||
|
$result2 = $htmlBuilder->mailto("person@example.com", "<span>First Name Last</span>", ["class" => "example-link"], false);
|
||||||
|
|
||||||
|
$this->assertEquals('<a href="mailto:person@example.com" class="example-link"><span>First Name Last</span></a>', $result1);
|
||||||
|
$this->assertEquals('<a href="mailto:person@example.com" class="example-link"><span>First Name Last</span></a>', $result2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user