Skip to content

Commit

Permalink
Use short array syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
bcrowe committed Feb 13, 2015
1 parent 55f461f commit 5b7d5d8
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/Growl.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Growl
*
* @var array
*/
protected $options = array();
protected $options = [];

/**
* Whether or not to escape the command arguments.
Expand All @@ -40,7 +40,7 @@ class Growl
*
* @var array
*/
protected $safe = array();
protected $safe = [];

/**
* Constructor.
Expand Down Expand Up @@ -166,7 +166,7 @@ public function setSafe($options)
*/
protected function escape(array $options)
{
$results = array();
$results = [];
foreach ($options as $key => $value) {
if (!in_array($key, $this->safe)) {
$results[$key] = escapeshellarg($value);
Expand Down
14 changes: 7 additions & 7 deletions tests/GrowlNotifyBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,35 @@ public function tearDown()

public function testBuild()
{
$options = array(
$options = [
'title' => 'Hello',
'message' => 'World',
'appIcon' => 'Mail',
'url' => 'http://www.example.com',
'sticky' => true
);
];
$expected = 'growlnotify -t Hello -m World -a Mail --url' .
' http://www.example.com -s';
$result = $this->GrowlNotifyBuilder->build($options);
$this->assertSame($expected, $result);

$options = array(
$options = [
'title' => 'Hello',
'message' => 'World',
'sticky' => false
);
];
$expected = 'growlnotify -t Hello -m World';
$result = $this->GrowlNotifyBuilder->build($options);
$this->assertSame($expected, $result);
}

public function testBuildWithAlias()
{
$options = array(
$options = [
'title' => 'Hello',
'message' => 'World',
'sticky' => true
);
];
$expected = 'grwl -t Hello -m World -s';
$result = $this->GrowlNotifyBuilderAliased->build($options);
$this->assertSame($expected, $result);
Expand All @@ -58,6 +58,6 @@ public function testBuildWithAlias()
*/
public function testAliasException()
{
$exception = new GrowlNotifyBuilder(array('no' => 'arraysplz'));
$exception = new GrowlNotifyBuilder(['no' => 'arraysplz']);
}
}
8 changes: 4 additions & 4 deletions tests/GrowlNotifyWindowsBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ public function tearDown()

public function testBuild()
{
$options = array(
$options = [
'title' => 'Hello',
'appIcon' => 'Mail',
'url' => 'http://www.example.com',
'message' => 'World',
'sticky' => true
);
];
$expected = 'growlnotify /t:Hello /ai:Mail /cu:' .
'http://www.example.com /s:true World';
$result = $this->GrowlNotifyWindowsBuilder->build($options);
$this->assertSame($expected, $result);

$options = array(
$options = [
'title' => 'Hello',
'message' => 'World',
'sticky' => false
);
];
$expected = 'growlnotify /t:Hello World';
$result = $this->GrowlNotifyWindowsBuilder->build($options);
$this->assertSame($expected, $result);
Expand Down
30 changes: 15 additions & 15 deletions tests/GrowlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public function testBuildCommand()
{
$expected = 'growlnotify -t \'Hello\' -m World';
$result = $this->Growl
->setOptions(array(
->setOptions([
'title' => 'Hello',
'message' => 'World'
))
])
->setSafe('message')
->buildCommand();

Expand All @@ -32,50 +32,50 @@ public function testBuildCommand()

public function testSet()
{
$expected = array(
$expected = [
'hello' => 'world',
'title' => 'Hey',
'message' => 'Whatsup?'
);
];

$result = $this->Growl->setOption('hello', 'world')
->setOption('title', 'Hey')
->setOption('message', 'Whatsup?');
$this->assertEquals($expected, PHPUnit_Framework_Assert::readAttribute($result, 'options'));

$result = $this->Growl->setOptions(array(
$result = $this->Growl->setOptions([
'hello' => 'world',
'title' => 'Hey',
'message' => 'Whatsup?'
));
]);
$this->assertEquals($expected, PHPUnit_Framework_Assert::readAttribute($result, 'options'));
}

public function testEscape()
{
$expected = array(
$expected = [
'hello' => '\'world\''
);
];

$growl = new Growl(new GrowlNotifyBuilder());
$growlReflection = new ReflectionClass($growl);
$method = $growlReflection->getMethod('escape');
$method->setAccessible(true);

$this->assertEquals($expected, $method->invokeArgs($growl, array(array('hello' => 'world'))));
$this->assertEquals($expected, $method->invokeArgs($growl, [['hello' => 'world']]));

$expected = array(
$expected = [
'hello' => '\'world\'',
'something' => 'else'
);
];

$growl = new Growl(new GrowlNotifyBuilder());
$growl->setSafe('something');
$growlReflection = new ReflectionClass($growl);
$method = $growlReflection->getMethod('escape');
$method->setAccessible(true);

$this->assertEquals($expected, $method->invokeArgs($growl, array(array('hello' => 'world', 'something' => 'else'))));
$this->assertEquals($expected, $method->invokeArgs($growl, [['hello' => 'world', 'something' => 'else']]));
}

public function testSetEscape()
Expand All @@ -86,12 +86,12 @@ public function testSetEscape()

public function testSetSafe()
{
$expected = array('hello');
$expected = ['hello'];
$growl = $this->Growl->setSafe('hello');
$this->assertEquals($expected, PHPUnit_Framework_Assert::readAttribute($growl, 'safe'));

$expected = array('hello', 'world', 'again');
$growl->setSafe(array('world', 'again'));
$expected = ['hello', 'world', 'again'];
$growl->setSafe(['world', 'again']);
$this->assertEquals($expected, PHPUnit_Framework_Assert::readAttribute($growl, 'safe'));
}

Expand Down
8 changes: 4 additions & 4 deletions tests/NotifySendBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ public function tearDown()

public function testBuild()
{
$options = array(
$options = [
'title' => 'Hello',
'message' => 'World',
'sticky' => true
);
];
$expected = 'notify-send Hello World -t 0';
$result = $this->NotifySendBuilder->build($options);
$this->assertSame($expected, $result);

$options = array(
$options = [
'title' => 'Hello',
'message' => 'Welcome'
);
];
$expected = 'notify-send Hello Welcome';
$result = $this->NotifySendBuilder->build($options);
$this->assertSame($expected, $result);
Expand Down
8 changes: 4 additions & 4 deletions tests/TerminalNotifierBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ public function tearDown()

public function testBuild()
{
$options = array(
$options = [
'title' => 'Hello',
'subtitle' => 'World',
'message' => 'Welcome',
'appIcon' => 'Mail',
'contentImage' => 'http://www.example.com/hello.jpg',
'open' => 'http://www.example.com'
);
];
$expected = 'terminal-notifier -title Hello -subtitle World -message Welcome' .
' -appIcon Mail -contentImage http://www.example.com/hello.jpg' .
' -open http://www.example.com';
$result = $this->TerminalNotifierBuilder->build($options);
$this->assertSame($expected, $result);

$options = array(
$options = [
'title' => 'Hello',
'message' => 'Welcome'
);
];
$expected = 'terminal-notifier -title Hello -message Welcome';
$result = $this->TerminalNotifierBuilder->build($options);
$this->assertSame($expected, $result);
Expand Down

0 comments on commit 5b7d5d8

Please sign in to comment.