Skip to content
This repository was archived by the owner on Feb 26, 2018. It is now read-only.

Commit

Permalink
DHH wouldn't approve, because it's not Ruby.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Leite committed Feb 19, 2016
1 parent 177bad3 commit c49d9e9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public function getOldInput($key)

protected function transformKey($key)
{
return str_replace(array('.', '[]', '[', ']'), array('_', '', '.', ''), $key);
return str_replace(['.', '[]', '[', ']'], ['_', '', '.', ''], $key);
}
}
4 changes: 2 additions & 2 deletions tests/IlluminateErrorStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class IlluminateErrorStoreTest extends PHPUnit_Framework_TestCase
{
public function test_it_converts_array_keys_to_dot_notation()
{
$errors = new MessageBag(array(
$errors = new MessageBag([
'foo.bar' => 'Some error',
));
]);
$session = Mockery::mock('Illuminate\Session\Store');
$session->shouldReceive('has')->with('errors')->andReturn(true);
$session->shouldReceive('get')->with('errors')->andReturn($errors);
Expand Down
88 changes: 44 additions & 44 deletions tests/SelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ protected function elementRegExp($attributes)

public function testSelectCanBeCreatedWithOptions()
{
$select = new Select('birth_year', array(1990, 1991, 1992));
$select = new Select('birth_year', [1990, 1991, 1992]);
$expected = '<select name="birth_year"><option value="0">1990</option><option value="1">1991</option><option value="2">1992</option></select>';
$result = $select->render();

$this->assertEquals($expected, $result);

$select = new Select('birth_year', array(2001, 2002, 2003));
$select = new Select('birth_year', [2001, 2002, 2003]);
$expected = '<select name="birth_year"><option value="0">2001</option><option value="1">2002</option><option value="2">2003</option></select>';
$result = $select->render();

Expand All @@ -36,13 +36,13 @@ public function testSelectCanBeCreatedWithOptions()

public function testSelectCanBeCreatedWithKeyValueOptions()
{
$select = new Select('color', array('red' => 'Red', 'blue' => 'Blue'));
$select = new Select('color', ['red' => 'Red', 'blue' => 'Blue']);
$expected = '<select name="color"><option value="red">Red</option><option value="blue">Blue</option></select>';
$result = $select->render();

$this->assertEquals($expected, $result);

$select = new Select('fruit', array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
$select = new Select('fruit', ['apple' => 'Granny Smith', 'berry' => 'Blueberry']);
$expected = '<select name="fruit"><option value="apple">Granny Smith</option><option value="berry">Blueberry</option></select>';
$result = $select->render();

Expand All @@ -51,14 +51,14 @@ public function testSelectCanBeCreatedWithKeyValueOptions()

public function testCanAddOption()
{
$select = new Select('color', array('red' => 'Red'));
$select = new Select('color', ['red' => 'Red']);
$select->addOption('blue', 'Blue');
$expected = '<select name="color"><option value="red">Red</option><option value="blue">Blue</option></select>';
$result = $select->render();

$this->assertEquals($expected, $result);

$select = new Select('fruit', array('apple' => 'Granny Smith'));
$select = new Select('fruit', ['apple' => 'Granny Smith']);
$select->addOption('berry', 'Blueberry');
$expected = '<select name="fruit"><option value="apple">Granny Smith</option><option value="berry">Blueberry</option></select>';
$result = $select->render();
Expand All @@ -69,14 +69,14 @@ public function testCanAddOption()
public function testCanSetOptions()
{
$select = new Select('color');
$select->options(array('red' => 'Red', 'blue' => 'Blue'));
$select->options(['red' => 'Red', 'blue' => 'Blue']);
$expected = '<select name="color"><option value="red">Red</option><option value="blue">Blue</option></select>';
$result = $select->render();

$this->assertEquals($expected, $result);

$select = new Select('fruit');
$select->options(array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
$select->options(['apple' => 'Granny Smith', 'berry' => 'Blueberry']);
$expected = '<select name="fruit"><option value="apple">Granny Smith</option><option value="berry">Blueberry</option></select>';
$result = $select->render();

Expand All @@ -86,14 +86,14 @@ public function testCanSetOptions()
public function testCanSetSelectedOption()
{
$select = new Select('color');
$select->options(array('red' => 'Red', 'blue' => 'Blue'));
$select->options(['red' => 'Red', 'blue' => 'Blue']);
$expected = '<select name="color"><option value="red">Red</option><option value="blue" selected>Blue</option></select>';
$result = $select->select('blue')->render();

$this->assertEquals($expected, $result);

$select = new Select('fruit');
$select->options(array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
$select->options(['apple' => 'Granny Smith', 'berry' => 'Blueberry']);
$expected = '<select name="fruit"><option value="apple" selected>Granny Smith</option><option value="berry">Blueberry</option></select>';
$result = $select->select('apple')->render();

Expand All @@ -103,14 +103,14 @@ public function testCanSetSelectedOption()
public function testCanSelectNumericKeys()
{
$select = new Select('fruit');
$select->options(array('1' => 'Granny Smith', '2' => 'Blueberry'));
$select->options(['1' => 'Granny Smith', '2' => 'Blueberry']);
$expected = '<select name="fruit"><option value="1" selected>Granny Smith</option><option value="2">Blueberry</option></select>';
$result = $select->select('1')->render();

$this->assertEquals($expected, $result);

$select = new Select('fruit');
$select->options(array('1' => 'Granny Smith', '2' => 'Blueberry'));
$select->options(['1' => 'Granny Smith', '2' => 'Blueberry']);
$expected = '<select name="fruit"><option value="1">Granny Smith</option><option value="2" selected>Blueberry</option></select>';
$result = $select->select('2')->render();

Expand All @@ -119,25 +119,25 @@ public function testCanSelectNumericKeys()

public function testCanSetDefaultOption()
{
$select = new Select('color', array('red' => 'Red', 'blue' => 'Blue'));
$select = new Select('color', ['red' => 'Red', 'blue' => 'Blue']);
$expected = '<select name="color"><option value="red">Red</option><option value="blue" selected>Blue</option></select>';
$result = $select->defaultValue('blue')->render();

$this->assertEquals($expected, $result);

$select = new Select('fruit', array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
$select = new Select('fruit', ['apple' => 'Granny Smith', 'berry' => 'Blueberry']);
$expected = '<select name="fruit"><option value="apple" selected>Granny Smith</option><option value="berry">Blueberry</option></select>';
$result = $select->defaultValue('apple')->render();

$this->assertEquals($expected, $result);

$select = new Select('fruit', array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
$select = new Select('fruit', ['apple' => 'Granny Smith', 'berry' => 'Blueberry']);
$expected = '<select name="fruit"><option value="apple">Granny Smith</option><option value="berry" selected>Blueberry</option></select>';
$result = $select->select('berry')->defaultValue('apple')->render();

$this->assertEquals($expected, $result);

$select = new Select('fruit', array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
$select = new Select('fruit', ['apple' => 'Granny Smith', 'berry' => 'Blueberry']);
$expected = '<select name="fruit"><option value="apple">Granny Smith</option><option value="berry" selected>Blueberry</option></select>';
$result = $select->defaultValue('apple')->select('berry')->render();

Expand All @@ -146,43 +146,43 @@ public function testCanSetDefaultOption()

public function testCanSetDefaultOptionMultiselect()
{
$select = new Select('color', array('red' => 'Red', 'blue' => 'Blue'));
$select = new Select('color', ['red' => 'Red', 'blue' => 'Blue']);
$expected = '<select name="color"><option value="red" selected>Red</option><option value="blue" selected>Blue</option></select>';
$result = $select->defaultValue(array('blue', 'red'))->render();
$result = $select->defaultValue(['blue', 'red'])->render();

$this->assertEquals($expected, $result);

$select = new Select('fruit', array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
$select = new Select('fruit', ['apple' => 'Granny Smith', 'berry' => 'Blueberry']);
$expected = '<select name="fruit"><option value="apple" selected>Granny Smith</option><option value="berry">Blueberry</option></select>';
$result = $select->defaultValue(array('apple'))->render();
$result = $select->defaultValue(['apple'])->render();

$this->assertEquals($expected, $result);

$select = new Select('fruit', array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
$select = new Select('fruit', ['apple' => 'Granny Smith', 'berry' => 'Blueberry']);
$expected = '<select name="fruit"><option value="apple">Granny Smith</option><option value="berry" selected>Blueberry</option></select>';
$result = $select->select('berry')->defaultValue(array('apple', 'berry'))->render();
$result = $select->select('berry')->defaultValue(['apple', 'berry'])->render();

$this->assertEquals($expected, $result);

$select = new Select('fruit', array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
$select = new Select('fruit', ['apple' => 'Granny Smith', 'berry' => 'Blueberry']);
$expected = '<select name="fruit"><option value="apple">Granny Smith</option><option value="berry" selected>Blueberry</option></select>';
$result = $select->defaultValue('apple')->select(array('berry'))->render();
$result = $select->defaultValue('apple')->select(['berry'])->render();

$this->assertEquals($expected, $result);
}

public function testCanUseNestedOptions()
{
$options = array(
'Ontario' => array(
$options = [
'Ontario' => [
'toronto' => 'Toronto',
'london' => 'London',
),
'Quebec' => array(
],
'Quebec' => [
'montreal' => 'Montreal',
'quebec-city' => 'Quebec City',
),
);
],
];
$select = new Select('color', $options);
$expected = '<select name="color"><optgroup label="Ontario"><option value="toronto">Toronto</option><option value="london">London</option></optgroup><optgroup label="Quebec"><option value="montreal">Montreal</option><option value="quebec-city">Quebec City</option></optgroup></select>';
$result = $select->render();
Expand All @@ -192,16 +192,16 @@ public function testCanUseNestedOptions()

public function testCanUseNestedOptionsWithoutKeys()
{
$options = array(
'Ontario' => array(
$options = [
'Ontario' => [
'Toronto',
'London',
),
'Quebec' => array(
],
'Quebec' => [
'Montreal',
'Quebec City',
),
);
],
];
$select = new Select('color', $options);
$expected = '<select name="color"><optgroup label="Ontario"><option value="0">Toronto</option><option value="1">London</option></optgroup><optgroup label="Quebec"><option value="0">Montreal</option><option value="1">Quebec City</option></optgroup></select>';
$result = $select->render();
Expand All @@ -211,14 +211,14 @@ public function testCanUseNestedOptionsWithoutKeys()

public function testCanMixNestedAndUnnestedOptions()
{
$options = array(
$options = [
'toronto' => 'Toronto',
'london' => 'London',
'Quebec' => array(
'Quebec' => [
'montreal' => 'Montreal',
'quebec-city' => 'Quebec City',
),
);
],
];
$select = new Select('color', $options);
$expected = '<select name="color"><option value="toronto">Toronto</option><option value="london">London</option><optgroup label="Quebec"><option value="montreal">Montreal</option><option value="quebec-city">Quebec City</option></optgroup></select>';
$result = $select->render();
Expand All @@ -228,12 +228,12 @@ public function testCanMixNestedAndUnnestedOptions()

public function testSelectCanBeCreatedWithIntegerKeyValueOptions()
{
$select = new Select('color', array('0' => 'Red', '1' => 'Blue'));
$select = new Select('color', ['0' => 'Red', '1' => 'Blue']);
$expected = '<select name="color"><option value="0">Red</option><option value="1">Blue</option></select>';
$result = $select->render();
$this->assertEquals($expected, $result);

$select = new Select('fruit', array('1' => 'Granny Smith', '0' => 'Blueberry'));
$select = new Select('fruit', ['1' => 'Granny Smith', '0' => 'Blueberry']);
$expected = '<select name="fruit"><option value="1">Granny Smith</option><option value="0">Blueberry</option></select>';
$result = $select->render();
$this->assertEquals($expected, $result);
Expand All @@ -256,9 +256,9 @@ public function testSelectCanBeMultiple()

public function testCanSelectMultipleElementsInMultiselects()
{
$select = new Select('color', array('red' => 'Red', 'blue' => 'Blue'));
$select = new Select('color', ['red' => 'Red', 'blue' => 'Blue']);
$expected = '<select name="color[]" multiple="multiple"><option value="red" selected>Red</option><option value="blue" selected>Blue</option></select>';
$result = $select->multiple()->select(array('red', 'blue'))->render();
$result = $select->multiple()->select(['red', 'blue'])->render();

$this->assertEquals($expected, $result);
}
Expand Down

0 comments on commit c49d9e9

Please sign in to comment.