From 369e8a22474a9a85da43c6b627c89c1fa0b6fd0e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 29 Jul 2019 16:43:24 +0200 Subject: [PATCH] Fix indenting --- src/Composer/Script/Event.php | 20 ++--- tests/Composer/Test/Script/EventTest.php | 109 ++++++++++++----------- 2 files changed, 68 insertions(+), 61 deletions(-) diff --git a/src/Composer/Script/Event.php b/src/Composer/Script/Event.php index 21aeb83ed..5fab172bf 100644 --- a/src/Composer/Script/Event.php +++ b/src/Composer/Script/Event.php @@ -39,9 +39,9 @@ class Event extends BaseEvent */ private $devMode; - /** - * @var BaseEvent - */ + /** + * @var BaseEvent + */ private $originatingEvent; /** @@ -100,7 +100,7 @@ class Event extends BaseEvent */ public function getOriginatingEvent() { - return $this->originatingEvent; + return $this->originatingEvent; } /** @@ -111,9 +111,9 @@ class Event extends BaseEvent */ public function setOriginatingEvent(BaseEvent $event) { - $this->originatingEvent = $this->calculateOriginatingEvent($event); + $this->originatingEvent = $this->calculateOriginatingEvent($event); - return $this; + return $this; } /** @@ -124,10 +124,10 @@ class Event extends BaseEvent */ private function calculateOriginatingEvent(BaseEvent $event) { - if ($event instanceof Event && $event->getOriginatingEvent()) { - return $this->calculateOriginatingEvent($event->getOriginatingEvent()); - } + if ($event instanceof Event && $event->getOriginatingEvent()) { + return $this->calculateOriginatingEvent($event->getOriginatingEvent()); + } - return $event; + return $event; } } diff --git a/tests/Composer/Test/Script/EventTest.php b/tests/Composer/Test/Script/EventTest.php index 2b8818500..b7c8cd9ff 100644 --- a/tests/Composer/Test/Script/EventTest.php +++ b/tests/Composer/Test/Script/EventTest.php @@ -1,73 +1,80 @@ + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Composer\Test\Script; - use Composer\Composer; use Composer\Config; use Composer\Script\Event; use Composer\Test\TestCase; -class EventTest extends TestCase { +class EventTest extends TestCase +{ + public function testEventSetsOriginatingEvent() + { + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); + $composer = $this->createComposerInstance(); - public function testEventSetsOriginatingEvent() { - $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); - $composer = $this->createComposerInstance(); + $originatingEvent = new \Composer\EventDispatcher\Event('originatingEvent'); - $originatingEvent = new \Composer\EventDispatcher\Event('originatingEvent'); + $scriptEvent = new Event('test', $composer, $io, true); - $scriptEvent = new Event('test', $composer, $io, true); + $this->assertNull( + $scriptEvent->getOriginatingEvent(), + 'originatingEvent is initialized as null' + ); - $this->assertNull( - $scriptEvent->getOriginatingEvent(), - 'originatingEvent is initialized as null' - ); + $scriptEvent->setOriginatingEvent($originatingEvent); - $scriptEvent->setOriginatingEvent($originatingEvent); + $this->assertSame( + $originatingEvent, + $scriptEvent->getOriginatingEvent(), + 'getOriginatingEvent() SHOULD return test event' + ); + } - $this->assertSame( - $originatingEvent, - $scriptEvent->getOriginatingEvent(), - 'getOriginatingEvent() SHOULD return test event' - ); + public function testEventCalculatesNestedOriginatingEvent() + { + $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); + $composer = $this->createComposerInstance(); - } + $originatingEvent = new \Composer\EventDispatcher\Event('upperOriginatingEvent'); + $intermediateEvent = new Event('intermediate', $composer, $io, true); + $intermediateEvent->setOriginatingEvent($originatingEvent); - public function testEventCalculatesNestedOriginatingEvent() { - $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); - $composer = $this->createComposerInstance(); + $scriptEvent = new Event('test', $composer, $io, true); + $scriptEvent->setOriginatingEvent($intermediateEvent); + $this->assertNotSame( + $intermediateEvent, + $scriptEvent->getOriginatingEvent(), + 'getOriginatingEvent() SHOULD NOT return intermediate events' + ); - $originatingEvent = new \Composer\EventDispatcher\Event('upperOriginatingEvent'); - $intermediateEvent = new Event('intermediate', $composer, $io, true); - $intermediateEvent->setOriginatingEvent($originatingEvent); + $this->assertSame( + $originatingEvent, + $scriptEvent->getOriginatingEvent(), + 'getOriginatingEvent() SHOULD return upper-most event' + ); + } - $scriptEvent = new Event('test', $composer, $io, true); - $scriptEvent->setOriginatingEvent($intermediateEvent); + private function createComposerInstance() + { + $composer = new Composer; + $config = new Config; + $composer->setConfig($config); + $package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock(); + $composer->setPackage($package); - $this->assertNotSame( - $intermediateEvent, - $scriptEvent->getOriginatingEvent(), - 'getOriginatingEvent() SHOULD NOT return intermediate events' - ); - - $this->assertSame( - $originatingEvent, - $scriptEvent->getOriginatingEvent(), - 'getOriginatingEvent() SHOULD return upper-most event' - ); - - } - - private function createComposerInstance() - { - $composer = new Composer; - $config = new Config; - $composer->setConfig($config); - $package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock(); - $composer->setPackage($package); - - return $composer; - } -} \ No newline at end of file + return $composer; + } +}