From 6cf3195b05574a01c3d849a5ee563549cdf0dc46 Mon Sep 17 00:00:00 2001 From: crynobone Date: Mon, 9 Mar 2015 18:36:49 +0800 Subject: [PATCH 1/2] Cache cs-fixer. Signed-off-by: crynobone --- .gitignore | 3 --- .php_cs | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 3b201a2..19aa429 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ # Composer composer.lock vendor/* - -# Build -.subsplit/ diff --git a/.php_cs b/.php_cs index 1a49e13..b178c57 100644 --- a/.php_cs +++ b/.php_cs @@ -7,6 +7,7 @@ $finder = Symfony\Component\Finder\Finder::create() ->ignoreVCS(true); return Symfony\CS\Config\Config::create() + ->setUsingCache(true) ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) ->fixers([ '-psr0', From fcf16f94221076752369e9e15ee73d25911eb74a Mon Sep 17 00:00:00 2001 From: crynobone Date: Tue, 10 Mar 2015 16:30:59 +0800 Subject: [PATCH 2/2] Run cs-fixer on tests. Signed-off-by: crynobone --- tests/CollectionTest.php | 8 +- tests/ExpressionTest.php | 2 +- tests/Ftp/ClientTest.php | 43 ++++--- tests/NestyTest.php | 118 +++++++++--------- tests/Providers/FilterServiceProviderTest.php | 4 +- tests/StrTest.php | 34 ++--- tests/Traits/MacroableTraitTest.php | 4 +- tests/Traits/ObservableTraitTest.php | 19 ++- tests/Traits/QueryFilterTraitTest.php | 4 +- tests/Traits/UploadedTraitTest.php | 18 +-- tests/Traits/ValidationTraitTest.php | 6 +- tests/ValidatorTest.php | 32 ++--- 12 files changed, 145 insertions(+), 147 deletions(-) diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index bbe0215..2aa2658 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -11,10 +11,10 @@ class CollectionTest extends \PHPUnit_Framework_TestCase */ public function testToCsvMethod() { - $stub = new Collection(array( - array('id' => 1, 'name' => 'Mior Muhammad Zaki'), - array('id' => 2, 'name' => 'Taylor Otwell'), - )); + $stub = new Collection([ + ['id' => 1, 'name' => 'Mior Muhammad Zaki'], + ['id' => 2, 'name' => 'Taylor Otwell'], + ]); $expected = <<stub = new Client(array( + $this->stub = new Client([ 'host' => 'sftp://localhost:22', 'user' => 'foo', 'password' => 'foobar', - )); + ]); } /** @@ -43,7 +43,7 @@ public function testInstanceOfFTP() { Morph::$prefix = '\Orchestra\Support\Ftp\TestCase\mock1_ftp_'; - $stub = Client::make(array('connection' => new StreamStub)); + $stub = Client::make(['connection' => new StreamStub()]); $this->assertInstanceOf('\Orchestra\Support\Ftp\Client', $stub); @@ -78,11 +78,11 @@ public function testConnectMethodSuccessful() $this->assertTrue($this->stub->connect()); $this->assertTrue($this->stub->connected()); - $stub = new Client(array( + $stub = new Client([ 'host' => 'ftp://localhost:21', 'user' => 'foo', 'password' => 'foobar', - )); + ]); $this->assertFalse($stub->connected()); $this->assertTrue($stub->connect()); @@ -98,10 +98,10 @@ public function testConnectMethodWhenHostIsNotDefined() { Morph::$prefix = '\Orchestra\Support\Ftp\TestCase\mock1_ftp_'; - $stub = new Client(array( + $stub = new Client([ 'user' => 'foo', 'password' => 'foobar', - )); + ]); $this->assertNull($stub->connect()); } @@ -115,11 +115,11 @@ public function testConnectMethodSFTPConnectThrowsException() { Morph::$prefix = '\Orchestra\Support\Ftp\TestCase\mock2_ftp_'; - $stub = new Client(array( + $stub = new Client([ 'host' => 'sftp://localhost:22', 'user' => 'foo', 'password' => 'foobar', - )); + ]); $stub->connect(); } @@ -133,11 +133,11 @@ public function testConnectMethodFTPConnectThrowsException() { Morph::$prefix = '\Orchestra\Support\Ftp\TestCase\mock2_ftp_'; - $stub = new Client(array( + $stub = new Client([ 'host' => 'ftp://localhost:21', 'user' => 'foo', 'password' => 'foobar', - )); + ]); $stub->connect(); } @@ -151,11 +151,11 @@ public function testConnectMethodFTPLoginThrowsException() { Morph::$prefix = '\Orchestra\Support\Ftp\TestCase\mock3_ftp_'; - $stub = new Client(array( + $stub = new Client([ 'host' => 'ftp://localhost:21', 'user' => 'foo', 'password' => 'foobar', - )); + ]); $stub->connect(); } @@ -178,7 +178,7 @@ public function testFTPFacadeMethodsSuccessful() $this->assertTrue($this->stub->rename('/var/www/home.php', '/var/www/dashboard.php')); $this->assertTrue($this->stub->delete('/var/www/home.php')); $this->assertTrue($this->stub->permission('/var/www/index.php', 755)); - $this->assertEquals(array('foo.php', 'foobar.php'), $this->stub->allFiles('/var/www/foo/')); + $this->assertEquals(['foo.php', 'foobar.php'], $this->stub->allFiles('/var/www/foo/')); $this->assertTrue($this->stub->makeDirectory('/var/www/orchestra')); $this->assertTrue($this->stub->removeDirectory('/var/www/orchestra')); } @@ -193,27 +193,26 @@ public function testFTPFacadeThrowsException() Morph::$prefix = '\Orchestra\Support\Ftp\TestCase\mock1_ftp_'; try { - Morph::fire('invalid_method', array('foo')); + Morph::fire('invalid_method', ['foo']); } catch (\Orchestra\Support\Ftp\RuntimeException $e) { $this->assertTrue(true, 'Excepted Exception'); - $this->assertEquals(array('foo'), $e->getParameters()); + $this->assertEquals(['foo'], $e->getParameters()); } } } class StreamStub { - } function mock1_ftp_ssl_connect() { - return new StreamStub; + return new StreamStub(); } function mock1_ftp_connect() { - return new StreamStub; + return new StreamStub(); } function mock1_ftp_login() @@ -273,7 +272,7 @@ function mock1_ftp_chmod() function mock1_ftp_nlist() { - return array('foo.php', 'foobar.php'); + return ['foo.php', 'foobar.php']; } function mock1_ftp_mkdir() @@ -298,12 +297,12 @@ function mock2_ftp_connect() function mock3_ftp_ssl_connect() { - return new StreamStub; + return new StreamStub(); } function mock3_ftp_connect() { - return new StreamStub; + return new StreamStub(); } function mock3_ftp_login() diff --git a/tests/NestyTest.php b/tests/NestyTest.php index d8555a8..e3f5f5c 100644 --- a/tests/NestyTest.php +++ b/tests/NestyTest.php @@ -18,7 +18,7 @@ class NestyTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->stub = new Nesty(array()); + $this->stub = new Nesty([]); } /** @@ -42,7 +42,7 @@ public function testInstanceOfNesty() $config = $refl->getProperty('config'); $config->setAccessible(true); - $this->assertEquals(array(), $config->getValue($this->stub)); + $this->assertEquals([], $config->getValue($this->stub)); } /** @@ -53,7 +53,7 @@ public function testInstanceOfNesty() */ public function testNewInstanceReturnEmptyArray() { - $this->assertEquals(new Collection(array()), with(new Nesty(array()))->items()); + $this->assertEquals(new Collection([]), with(new Nesty([]))->items()); } /** @@ -63,53 +63,53 @@ public function testNewInstanceReturnEmptyArray() */ public function testAddMethod() { - $foobar = new Fluent(array( + $foobar = new Fluent([ 'id' => 'foobar', - 'childs' => array( - 'hello-foobar' => new Fluent(array( + 'childs' => [ + 'hello-foobar' => new Fluent([ 'id' => 'hello-foobar', - 'childs' => array(), - )), - ), - )); - $foo = new Fluent(array( + 'childs' => [], + ]), + ], + ]); + $foo = new Fluent([ 'id' => 'foo', - 'childs' => array( - 'bar' => new Fluent(array( + 'childs' => [ + 'bar' => new Fluent([ 'id' => 'bar', - 'childs' => array(), - )), - 'foobar' => $foobar, - 'foo-bar' => new Fluent(array( + 'childs' => [], + ]), + 'foobar' => $foobar, + 'foo-bar' => new Fluent([ 'id' => 'foo-bar', - 'childs' => array(), - )), - 'hello-world-foobar' => new Fluent(array( + 'childs' => [], + ]), + 'hello-world-foobar' => new Fluent([ 'id' => 'hello-world-foobar', - 'childs' => array(), - )), - ) - )); + 'childs' => [], + ]), + ], + ]); - $expected = array( - 'crynobone' => new Fluent(array( + $expected = [ + 'crynobone' => new Fluent([ 'id' => 'crynobone', - 'childs' => array(), - )), - 'hello' => new Fluent(array( + 'childs' => [], + ]), + 'hello' => new Fluent([ 'id' => 'hello', - 'childs' => array(), - )), - 'world' => new Fluent(array( + 'childs' => [], + ]), + 'world' => new Fluent([ 'id' => 'world', - 'childs' => array(), - )), - 'foo' => $foo, - 'orchestra' => new Fluent(array( + 'childs' => [], + ]), + 'foo' => $foo, + 'orchestra' => new Fluent([ 'id' => 'orchestra', - 'childs' => array(), - )), - ); + 'childs' => [], + ]), + ]; $this->stub->add('foo'); $this->stub->add('hello', '<:foo'); @@ -134,18 +134,18 @@ public function testAddMethod() */ public function testAddBeforeMethod() { - $stub = new Nesty(array()); + $stub = new Nesty([]); - $expected = array( - 'foobar' => new Fluent(array( + $expected = [ + 'foobar' => new Fluent([ 'id' => 'foobar', - 'childs' => array(), - )), - 'foo' => new Fluent(array( + 'childs' => [], + ]), + 'foo' => new Fluent([ 'id' => 'foo', - 'childs' => array(), - )), - ); + 'childs' => [], + ]), + ]; $stub->add('foo', '<:home'); $stub->add('foobar', '<:foo'); @@ -158,18 +158,18 @@ public function testAddBeforeMethod() */ public function testAddAfterMethod() { - $stub = new Nesty(array()); + $stub = new Nesty([]); - $expected = array( - 'foobar' => new Fluent(array( + $expected = [ + 'foobar' => new Fluent([ 'id' => 'foobar', - 'childs' => array(), - )), - 'foo' => new Fluent(array( + 'childs' => [], + ]), + 'foo' => new Fluent([ 'id' => 'foo', - 'childs' => array(), - )), - ); + 'childs' => [], + ]), + ]; $stub->add('foobar', '>:home'); $stub->add('foo', '>:foobar'); @@ -185,9 +185,9 @@ public function testAddAfterMethod() */ public function testAddMethodWhenDecendantIsNotPresented() { - $stub = new Nesty(array()); + $stub = new Nesty([]); $stub->add('foo', '^:home'); - $this->assertEquals(new Collection(array()), $stub->items()); + $this->assertEquals(new Collection([]), $stub->items()); } } diff --git a/tests/Providers/FilterServiceProviderTest.php b/tests/Providers/FilterServiceProviderTest.php index b087dd7..94f72e0 100644 --- a/tests/Providers/FilterServiceProviderTest.php +++ b/tests/Providers/FilterServiceProviderTest.php @@ -22,7 +22,7 @@ public function tearDown() */ public function testBootMethod() { - $app = new Container; + $app = new Container(); $router = $app['router'] = m::mock('\Illuminate\Routing\Router'); @@ -38,5 +38,5 @@ public function testBootMethod() class StubFilterProvider extends FilterServiceProvider { protected $before = ['BeforeFilter']; - protected $after = ['AfterFilter']; + protected $after = ['AfterFilter']; } diff --git a/tests/StrTest.php b/tests/StrTest.php index befebcb..2086a95 100644 --- a/tests/StrTest.php +++ b/tests/StrTest.php @@ -25,20 +25,20 @@ public function testHumanizeMethod() public function testReplaceMethod() { $expected = 'Orchestra Platform is awesome'; - $output = Str::replace('{name} is awesome', array('name' => 'Orchestra Platform')); + $output = Str::replace('{name} is awesome', ['name' => 'Orchestra Platform']); $this->assertEquals($expected, $output); - $expected = array( + $expected = [ 'Orchestra Platform is awesome', 'Orchestra Platform is not a foobar', - ); + ]; - $data = array( + $data = [ '{name} is awesome', '{name} is not a {foo}', - ); - $output = Str::replace($data, array('name' => 'Orchestra Platform', 'foo' => 'foobar')); + ]; + $output = Str::replace($data, ['name' => 'Orchestra Platform', 'foo' => 'foobar']); $this->assertEquals($expected, $output); } @@ -50,12 +50,12 @@ public function testReplaceMethod() */ public function testSearchableMethod() { - $expected = array('foobar%'); + $expected = ['foobar%']; $output = Str::searchable('foobar*'); $this->assertEquals($expected, $output); - $expected = array('foobar', 'foobar%', '%foobar', '%foobar%'); + $expected = ['foobar', 'foobar%', '%foobar', '%foobar%']; $output = Str::searchable('foobar'); $this->assertEquals($expected, $output); @@ -75,13 +75,13 @@ public function testStreamGetContentsMethod() $this->assertEquals($expected, $output); - $expected = array( + $expected = [ 'name' => 'Orchestra', - 'theme' => array( - 'backend' => 'default', + 'theme' => [ + 'backend' => 'default', 'frontend' => 'default', - ), - ); + ], + ]; $this->assertEquals($expected, unserialize($output)); @@ -91,13 +91,13 @@ public function testStreamGetContentsMethod() $this->assertEquals($expected, $output); - $expected = array( + $expected = [ 'name' => 'Orchestra', - 'theme' => array( + 'theme' => [ 'backend' => 'default', 'frontend' => 'default', - ), - ); + ], + ]; $this->assertEquals($expected, unserialize($output)); $this->assertEquals('foo', Str::streamGetContents('foo')); diff --git a/tests/Traits/MacroableTraitTest.php b/tests/Traits/MacroableTraitTest.php index e475b23..663423b 100644 --- a/tests/Traits/MacroableTraitTest.php +++ b/tests/Traits/MacroableTraitTest.php @@ -11,7 +11,7 @@ class MacroableTraitTest extends \PHPUnit_Framework_TestCase */ public function testMacroIsExecutable() { - $stub = new MacroableStub; + $stub = new MacroableStub(); $stub->macro('foo', function () { return 'foobar'; @@ -29,7 +29,7 @@ public function testMacroIsExecutable() */ public function testMacroThrowsExceptionWhenMacroIsntExecutable() { - with(new MacroableStub)->foo(); + with(new MacroableStub())->foo(); } } diff --git a/tests/Traits/ObservableTraitTest.php b/tests/Traits/ObservableTraitTest.php index ea6a90d..26fb7e8 100644 --- a/tests/Traits/ObservableTraitTest.php +++ b/tests/Traits/ObservableTraitTest.php @@ -41,11 +41,11 @@ public function testEventDispatcher() */ public function testGetObservableEventsMethod() { - $stub1 = new ObservableStub; - $stub2 = new ObservableStubWithoutEvents; + $stub1 = new ObservableStub(); + $stub2 = new ObservableStubWithoutEvents(); - $this->assertEquals(array('saving', 'saved'), $stub1->getObservableEvents()); - $this->assertEquals(array(), $stub2->getObservableEvents()); + $this->assertEquals(['saving', 'saved'], $stub1->getObservableEvents()); + $this->assertEquals([], $stub2->getObservableEvents()); } /** @@ -58,9 +58,9 @@ public function testObserveWithoutDispatcher() { ObservableStub::flushEventListeners(); - ObservableStub::observe(new FoobarObserver); + ObservableStub::observe(new FoobarObserver()); - $stub = new ObservableStub; + $stub = new ObservableStub(); $stub->save(); $this->assertFalse($stub->saving); @@ -77,7 +77,7 @@ public function testObserveWithDispatcher() { $dispatcher = m::mock('\Illuminate\Events\Dispatcher'); - $stub = new ObservableStub; + $stub = new ObservableStub(); $dispatcher->shouldReceive('listen')->once() ->with('saving: '.__NAMESPACE__.'\\ObservableStub', __NAMESPACE__.'\\FoobarObserver@saving') @@ -94,7 +94,7 @@ public function testObserveWithDispatcher() ObservableStub::setEventDispatcher($dispatcher); - ObservableStub::observe(new FoobarObserver); + ObservableStub::observe(new FoobarObserver()); $stub->save(); @@ -103,7 +103,6 @@ public function testObserveWithDispatcher() ObservableStub::flushEventListeners(); } - } class ObservableStub @@ -122,7 +121,7 @@ public function save() public function getObservableEvents() { - return array('saving', 'saved'); + return ['saving', 'saved']; } } diff --git a/tests/Traits/QueryFilterTraitTest.php b/tests/Traits/QueryFilterTraitTest.php index 8c1e923..37cbd5f 100644 --- a/tests/Traits/QueryFilterTraitTest.php +++ b/tests/Traits/QueryFilterTraitTest.php @@ -36,7 +36,7 @@ public function testSetupBasicQueryFilterMethod() $this->assertEquals($query, $this->setupBasicQueryFilter($query, [ 'order_by' => 'created', 'direction' => 'desc', - 'columns' => ['only' => 'created_at'], + 'columns' => ['only' => 'created_at'], ])); } @@ -55,7 +55,7 @@ public function testSetupBasicQueryFilterMethodGivenColumnExcluded() $this->assertEquals($query, $this->setupBasicQueryFilter($query, [ 'order_by' => 'password', 'direction' => 'desc', - 'columns' => ['except' => 'password'], + 'columns' => ['except' => 'password'], ])); } diff --git a/tests/Traits/UploadedTraitTest.php b/tests/Traits/UploadedTraitTest.php index 0c9fe81..2f862f9 100644 --- a/tests/Traits/UploadedTraitTest.php +++ b/tests/Traits/UploadedTraitTest.php @@ -13,7 +13,7 @@ class UploadedTraitTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $app = new Container; + $app = new Container(); Facade::clearResolvedInstances(); Facade::setFacadeApplication($app); @@ -32,15 +32,15 @@ public function tearDown() public function testSaveUploadedFileMethod() { $path = '/var/www/public/'; - $file = m::mock('\Symfony\Component\HttpFoundation\File\UploadedFile[getClientOriginalExtension,move]', array( + $file = m::mock('\Symfony\Component\HttpFoundation\File\UploadedFile[getClientOriginalExtension,move]', [ realpath(__DIR__.'/fixtures').'/test.gif', 'test', - )); + ]); $file->shouldReceive('getClientOriginalExtension')->once()->andReturn('jpg') ->shouldReceive('move')->once()->with($path, m::type('String'))->andReturnNull(); - $stub = new UploadedStub; + $stub = new UploadedStub(); $filename = $stub->save($file, $path); } @@ -54,14 +54,14 @@ public function testSaveUploadedFileMethod() public function testSaveUploadedFileMethodWithCustomFilename() { $path = '/var/www/public/'; - $file = m::mock('\Symfony\Component\HttpFoundation\File\UploadedFile[move]', array( + $file = m::mock('\Symfony\Component\HttpFoundation\File\UploadedFile[move]', [ realpath(__DIR__.'/fixtures').'/test.gif', 'test', - )); + ]); $file->shouldReceive('move')->once()->with($path, 'foo.jpg')->andReturnNull(); - $stub = new UploadedStubWithReplacement; + $stub = new UploadedStubWithReplacement(); $filename = $stub->save($file, $path); } @@ -74,13 +74,13 @@ public function testSaveUploadedFileMethodWithCustomFilename() public function testDeleteMethod() { $filesystem = m::mock('\Illuminate\Filesystem\Filesystem'); - $filename = '/var/www/foo.jpg'; + $filename = '/var/www/foo.jpg'; $filesystem->shouldReceive('delete')->once()->with($filename)->andReturn(true); File::swap($filesystem); - $stub = new UploadedStub; + $stub = new UploadedStub(); $this->assertTrue($stub->delete($filename)); } diff --git a/tests/Traits/ValidationTraitTest.php b/tests/Traits/ValidationTraitTest.php index 799d35f..28bff6f 100644 --- a/tests/Traits/ValidationTraitTest.php +++ b/tests/Traits/ValidationTraitTest.php @@ -13,8 +13,8 @@ class ValidationTraitTest extends \PHPUnit_Framework_TestCase */ public function testGetValidationHelpers() { - $this->assertEquals(array(), $this->getValidationEvents()); - $this->assertEquals(array(), $this->getValidationPhrases()); - $this->assertEquals(array(), $this->getValidationRules()); + $this->assertEquals([], $this->getValidationEvents()); + $this->assertEquals([], $this->getValidationPhrases()); + $this->assertEquals([], $this->getValidationRules()); } } diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index 08b7e7c..04c284f 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -23,7 +23,7 @@ public function tearDown() } /** - * Test Orchestra\Support\Validator + * Test Orchestra\Support\Validator. * * @test */ @@ -32,17 +32,17 @@ public function testValidation() $event = m::mock('\Illuminate\Contracts\Events\Dispatcher'); $validator = m::mock('\Illuminate\Contracts\Validation\Factory'); - $rules = array('email' => array('email', 'foo:2'), 'name' => 'any'); - $phrases = array('email.required' => 'Email required'); + $rules = ['email' => ['email', 'foo:2'], 'name' => 'any']; + $phrases = ['email.required' => 'Email required']; $event->shouldReceive('fire')->once()->with('foo.event', m::any())->andReturn(null); - $validator->shouldReceive('make')->once()->with(array(), $rules, $phrases) + $validator->shouldReceive('make')->once()->with([], $rules, $phrases) ->andReturn(m::mock('\Illuminate\Validation\Validator')); $stub = new FooValidator($validator, $event); - $stub->on('foo', array('orchestra'))->bind(array('id' => '2')); + $stub->on('foo', ['orchestra'])->bind(['id' => '2']); - $validation = $stub->with(array(), 'foo.event'); + $validation = $stub->with([], 'foo.event'); $this->assertEquals('orchestra', $_SERVER['validator.onFoo']); $this->assertEquals($validation, $_SERVER['validator.extendFoo']); @@ -59,16 +59,16 @@ public function testValidationWithoutAScope() $event = m::mock('\Illuminate\Contracts\Events\Dispatcher'); $validator = m::mock('\Illuminate\Contracts\Validation\Factory'); - $rules = array('email' => array('email', 'foo:2'), 'name' => 'any'); - $phrases = array('email.required' => 'Email required', 'name' => 'Any name'); + $rules = ['email' => ['email', 'foo:2'], 'name' => 'any']; + $phrases = ['email.required' => 'Email required', 'name' => 'Any name']; - $validator->shouldReceive('make')->once()->with(array(), $rules, $phrases) + $validator->shouldReceive('make')->once()->with([], $rules, $phrases) ->andReturn(m::mock('\Illuminate\Validation\Validator')); $stub = new FooValidator($validator, $event); - $stub->bind(array('id' => '2')); + $stub->bind(['id' => '2']); - $validation = $stub->with(array(), null, array('name' => 'Any name')); + $validation = $stub->with([], null, ['name' => 'Any name']); $this->assertInstanceOf('\Illuminate\Validation\Validator', $validation); } @@ -76,14 +76,14 @@ public function testValidationWithoutAScope() class FooValidator extends \Orchestra\Support\Validator { - protected $rules = array( - 'email' => array('email', 'foo:{id}'), + protected $rules = [ + 'email' => ['email', 'foo:{id}'], 'name' => 'any', - ); + ]; - protected $phrases = array( + protected $phrases = [ 'email.required' => 'Email required', - ); + ]; protected function onFoo($value) {