1
0
Fork 0

Fix indenting

pull/8186/head
Jordi Boggiano 2019-07-29 16:43:24 +02:00
parent b51cfce8e6
commit 369e8a2247
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 68 additions and 61 deletions

View File

@ -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;
}
}

View File

@ -1,73 +1,80 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* 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;
}
}
return $composer;
}
}