Skip to content

Commit

Permalink
Updating the package
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc committed Oct 2, 2019
1 parent eacca0e commit f7d1523
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"license": "MIT",
"require": {
"php": ">=7.2.0",
"illuminate/support": "~6.0"
"illuminate/support": "^6.0"
},
"require-dev": {
"ext-dom": "*",
"phpunit/phpunit": "~8.0",
"phpunit/phpcov": "~6.0"
"phpunit/phpunit": "^8.0",
"phpunit/phpcov": "^6.0"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 9 additions & 3 deletions src/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,20 @@ public function time($name = null, $value = null, $format = true)
/**
* Make a number input.
*
* @param string $name
* @param string|null $name
* @param string|null $value
* @param mixed|null $min
* @param mixed|null $max
* @param mixed|null $step
*
* @return \Arcanedev\Html\Elements\Input
*/
public function number($name, $value = null)
public function number($name = null, $value = null, $min = null, $max = null, $step = null)
{
return $this->input('number', $name, $value);
return $this->input('number', $name, $value)
->attributeIfNotNull($min, 'min', $min)
->attributeIfNotNull($max, 'max', $max)
->attributeIfNotNull($step, 'step', $step);
}

/**
Expand Down
24 changes: 24 additions & 0 deletions tests/Html/InputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,36 @@ public function it_can_make_text_input()
/** @test */
public function it_can_make_number_input()
{
static::assertHtmlStringEqualsHtmlString(
'<input type="number">',
$this->html->number()
);

static::assertHtmlStringEqualsHtmlString(
'<input type="number" id="price" name="price" value="120">',
$this->html->number('price', 120)
);
}

/** @test */
public function it_can_make_a_number_input_with_min_max_step()
{
static::assertHtmlStringEqualsHtmlString(
'<input type="number" name="percentage" id="percentage" value="0" min="0" max="100">',
$this->html->number('percentage', '0', '0', '100')
);

static::assertHtmlStringEqualsHtmlString(
'<input type="number" name="percentage" id="percentage" value="0" min="0" max="100" step="10">',
$this->html->number('percentage', '0', '0', '100', '10')
);

static::assertHtmlStringEqualsHtmlString(
'<input type="number" name="percentage" id="percentage" value="30" max="100" step="10">',
$this->html->number('percentage', '30', null, '100', '10')
);
}

/** @test */
public function it_avoids_fill_value_for_password_input()
{
Expand Down

0 comments on commit f7d1523

Please sign in to comment.