From 03a81a3283d73ae55bf98c79e7b29075dc10643c Mon Sep 17 00:00:00 2001 From: meadsteve Date: Mon, 25 Nov 2013 21:19:48 +0000 Subject: [PATCH] fix whitespace. --- Tests/PHPCI/Plugin/EmailTest.php | 186 +++++++++++----------- Tests/PHPCI/Plugin/PHPUnitTest.php | 240 +++++++++++++++-------------- 2 files changed, 225 insertions(+), 201 deletions(-) diff --git a/Tests/PHPCI/Plugin/EmailTest.php b/Tests/PHPCI/Plugin/EmailTest.php index 1343068c..1899c99c 100644 --- a/Tests/PHPCI/Plugin/EmailTest.php +++ b/Tests/PHPCI/Plugin/EmailTest.php @@ -1,32 +1,33 @@ mockBuild = $this->getMock( - '\PHPCI\Model\Build', - array('getLog', 'getStatus'), - array(), - "mockBuild", - false - ); + '\PHPCI\Model\Build', + array('getLog', 'getStatus'), + array(), + "mockBuild", + false + ); $this->mockBuild->expects($this->any()) ->method('getLog') @@ -56,27 +57,33 @@ class EmailTest extends \PHPUnit_Framework_TestCase ->method('getStatus') ->will($this->returnValue(\PHPCI\Model\Build::STATUS_SUCCESS)); - $this->mockCiBuilder = $this->getMock( - '\PHPCI\Builder', - array('getSystemConfig', - 'getBuildProjectTitle', - 'getBuild', - 'log'), - array(), - "mockBuilder", - false - ); + $this->mockCiBuilder = $this->getMock( + '\PHPCI\Builder', + array( + 'getSystemConfig', + 'getBuildProjectTitle', + 'getBuild', + 'log' + ), + array(), + "mockBuilder", + false + ); $this->mockCiBuilder->buildPath = "/"; $this->mockCiBuilder->expects($this->any()) ->method('getSystemConfig') ->with('phpci') - ->will($this->returnValue(array( - 'email_settings' => array( - 'from_address' => "test-from-address@example.com" + ->will( + $this->returnValue( + array( + 'email_settings' => array( + 'from_address' => "test-from-address@example.com" + ) + ) ) - ))); + ); $this->mockCiBuilder->expects($this->any()) ->method('getBuildProjectTitle') ->will($this->returnValue('Test-Project')); @@ -85,53 +92,55 @@ class EmailTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->mockBuild)); $this->mockMailer = $this->getMock( - '\Swift_Mailer', - array('send'), - array(), - "mockMailer", - false - ); + '\Swift_Mailer', + array('send'), + array(), + "mockMailer", + false + ); - $this->loadEmailPluginWithOptions(); - } + $this->loadEmailPluginWithOptions(); + } - protected function loadEmailPluginWithOptions($arrOptions = array()) - { - $this->testedEmailPlugin = new EmailPlugin( + protected function loadEmailPluginWithOptions($arrOptions = array()) + { + $this->testedEmailPlugin = new EmailPlugin( $this->mockCiBuilder, $this->mockBuild, $this->mockMailer, $arrOptions ); - } + } - /** - * @covers PHPUnit::execute - */ - public function testExecute_ReturnsFalseWithoutArgs() - { - $returnValue = $this->testedEmailPlugin->execute(); + /** + * @covers PHPUnit::execute + */ + public function testExecute_ReturnsFalseWithoutArgs() + { + $returnValue = $this->testedEmailPlugin->execute(); // As no addresses will have been mailed as non are configured. - $expectedReturn = false; + $expectedReturn = false; - $this->assertEquals($expectedReturn, $returnValue); - } + $this->assertEquals($expectedReturn, $returnValue); + } - /** - * @covers PHPUnit::execute - */ - public function testExecute_BuildsBasicEmails() - { - $this->loadEmailPluginWithOptions(array( - 'addresses' => array('test-receiver@example.com') - )); + /** + * @covers PHPUnit::execute + */ + public function testExecute_BuildsBasicEmails() + { + $this->loadEmailPluginWithOptions( + array( + 'addresses' => array('test-receiver@example.com') + ) + ); /** @var \Swift_Message $actualMail */ $actualMail = null; $this->catchMailPassedToSend($actualMail); - $returnValue = $this->testedEmailPlugin->execute(); - $expectedReturn = true; + $returnValue = $this->testedEmailPlugin->execute(); + $expectedReturn = true; $this->assertSystemMail( 'test-receiver@example.com', @@ -141,14 +150,14 @@ class EmailTest extends \PHPUnit_Framework_TestCase $actualMail ); - $this->assertEquals($expectedReturn, $returnValue); + $this->assertEquals($expectedReturn, $returnValue); - } + } /** - * @covers PHPUnit::sendEmail - */ + * @covers PHPUnit::sendEmail + */ public function testSendEmail_CallsMailerSend() { $this->mockMailer->expects($this->once()) @@ -157,8 +166,8 @@ class EmailTest extends \PHPUnit_Framework_TestCase } /** - * @covers PHPUnit::sendEmail - */ + * @covers PHPUnit::sendEmail + */ public function testSendEmail_BuildsAMessageObject() { $subject = "Test mail"; @@ -172,8 +181,8 @@ class EmailTest extends \PHPUnit_Framework_TestCase } /** - * @covers PHPUnit::sendEmail - */ + * @covers PHPUnit::sendEmail + */ public function testSendEmail_BuildsExpectedMessage() { $subject = "Test mail"; @@ -200,7 +209,7 @@ class EmailTest extends \PHPUnit_Framework_TestCase } /** - * @param \Swift_Message $actualMail passed by ref and populated with + * @param \Swift_Message $actualMail passed by ref and populated with * the message object the mock mailer * receives. */ @@ -227,14 +236,17 @@ class EmailTest extends \PHPUnit_Framework_TestCase * @param string $expectedSubject * @param \Swift_Message $actualMail */ - protected function assertSystemMail($expectedToAddress, - $expectedFromAddress, - $expectedBody, - $expectedSubject, - $actualMail) - { - if (! ($actualMail instanceof \Swift_Message)) { - $type = is_object($actualMail) ? get_class($actualMail) : gettype($actualMail); + protected function assertSystemMail( + $expectedToAddress, + $expectedFromAddress, + $expectedBody, + $expectedSubject, + $actualMail + ) { + if (!($actualMail instanceof \Swift_Message)) { + $type = is_object($actualMail) ? get_class($actualMail) : gettype( + $actualMail + ); throw new \Exception("Expected Swift_Message got " . $type); } $this->assertEquals( diff --git a/Tests/PHPCI/Plugin/PHPUnitTest.php b/Tests/PHPCI/Plugin/PHPUnitTest.php index 5809ac67..dec0dd3f 100644 --- a/Tests/PHPCI/Plugin/PHPUnitTest.php +++ b/Tests/PHPCI/Plugin/PHPUnitTest.php @@ -1,71 +1,73 @@ mockCiBuilder = $this->getMock( - '\PHPCI\Builder', - array(), - array(), - "mockBuilder", - false - ); - $this->mockCiBuilder->buildPath = "/"; + /** + * @var \PHPUnit_Framework_MockObject_MockObject $mockCiBuilder + */ + protected $mockBuild; + + public function setUp() + { + $this->mockCiBuilder = $this->getMock( + '\PHPCI\Builder', + array('findBinary'), + array(), + "mockBuilder", + false + ); + $this->mockCiBuilder->buildPath = "/"; $this->mockBuild = $this->getMock( - '\PHPCI\Model\Build', - array(), - array(), - "MockBuild", - false - ); + '\PHPCI\Model\Build', + array(), + array(), + "MockBuild", + false + ); - $this->loadPhpUnitWithOptions(); - } + $this->loadPhpUnitWithOptions(); + } - protected function loadPhpUnitWithOptions($arrOptions = array()) - { - $this->testedPhpUnit = new PHPUnit($this->mockCiBuilder,$this->mockBuild, $arrOptions); - } + protected function loadPhpUnitWithOptions($arrOptions = array()) + { + $this->testedPhpUnit = new PHPUnit($this->mockCiBuilder, $this->mockBuild, $arrOptions); + } /** * @param \PHPUnit_Framework_MockObject_Matcher_Invocation $expectation */ - protected function expectFindBinaryToBeCalled($expectation) { + protected function expectFindBinaryToBeCalled($expectation) + { $this->mockCiBuilder->expects($expectation) - ->method("findBinary") - ->will($this->returnValue("phpunit")); + ->method("findBinary") + ->will($this->returnValue("phpunit")); } /** @@ -74,89 +76,99 @@ class PHPUnitTest extends \PHPUnit_Framework_TestCase public function expectExectuteCommandToBeCalled($expectation) { $this->mockCiBuilder->expects($expectation) - ->method("executeCommand"); + ->method("executeCommand"); } - /** - * @covers PHPUnit::execute - */ - public function testExecute_ReturnsTrueWithoutArgs() - { - $returnValue = $this->testedPhpUnit->execute(); - $expectedReturn = true; + /** + * @covers PHPUnit::execute + */ + public function testExecute_ReturnsTrueWithoutArgs() + { + $returnValue = $this->testedPhpUnit->execute(); + $expectedReturn = true; - $this->assertEquals($expectedReturn, $returnValue); - } + $this->assertEquals($expectedReturn, $returnValue); + } - /** - * @covers PHPUnit::execute - * @covers PHPUnit::runDir - */ - public function testExecute_CallsExecuteCommandOnceWhenGivenStringDirectory() - { - chdir('/'); + /** + * @covers PHPUnit::execute + * @covers PHPUnit::runDir + */ + public function testExecute_CallsExecuteCommandOnceWhenGivenStringDirectory( + ) + { + chdir('/'); - $this->loadPhpUnitWithOptions(array( - 'directory' => "Fake/Test/Path" - )); - - $this->expectFindBinaryToBeCalled($this->once()); - $this->expectExectuteCommandToBeCalled($this->once()); - - $returnValue = $this->testedPhpUnit->execute(); - } - - /** - * @covers PHPUnit::execute - * @covers PHPUnit::runConfigFile - */ - public function testExecute_CallsExecuteCommandOnceWhenGivenStringConfig() - { - chdir('/'); - - $this->loadPhpUnitWithOptions(array( - 'config' => "Fake/Test/config.xml" - )); + $this->loadPhpUnitWithOptions( + array( + 'directory' => "Fake/Test/Path" + ) + ); $this->expectFindBinaryToBeCalled($this->once()); $this->expectExectuteCommandToBeCalled($this->once()); $returnValue = $this->testedPhpUnit->execute(); - } + } - /** - * @covers PHPUnit::execute - * @covers PHPUnit::runDir - */ - public function testExecute_CallsExecuteCommandManyTimesWhenGivenArrayDirectory() - { - chdir('/'); + /** + * @covers PHPUnit::execute + * @covers PHPUnit::runConfigFile + */ + public function testExecute_CallsExecuteCommandOnceWhenGivenStringConfig() + { + chdir('/'); - $this->loadPhpUnitWithOptions(array( - 'directory' => array(0, 1) - )); + $this->loadPhpUnitWithOptions( + array( + 'config' => "Fake/Test/config.xml" + ) + ); - $this->mockCiBuilder->expects($this->at(0))->method("executeCommand"); - $this->mockCiBuilder->expects($this->at(1))->method("executeCommand"); + $this->expectFindBinaryToBeCalled($this->once()); + $this->expectExectuteCommandToBeCalled($this->once()); - $returnValue = $this->testedPhpUnit->execute(); - } + $returnValue = $this->testedPhpUnit->execute(); + } - /** - * @covers PHPUnit::execute - * @covers PHPUnit::runConfigFile - */ - public function testExecute_CallsExecuteCommandManyTimesWhenGivenArrayConfig() - { - chdir('/'); + /** + * @covers PHPUnit::execute + * @covers PHPUnit::runDir + */ + public function testExecute_CallsExecuteCommandManyTimesWhenGivenArrayDirectory( + ) + { + chdir('/'); - $this->loadPhpUnitWithOptions(array( - 'config' => array(0, 1) - )); + $this->loadPhpUnitWithOptions( + array( + 'directory' => array(0, 1) + ) + ); - $this->mockCiBuilder->expects($this->at(0))->method("executeCommand"); - $this->mockCiBuilder->expects($this->at(1))->method("executeCommand"); + $this->mockCiBuilder->expects($this->at(0))->method("executeCommand"); + $this->mockCiBuilder->expects($this->at(1))->method("executeCommand"); - $returnValue = $this->testedPhpUnit->execute(); - } + $returnValue = $this->testedPhpUnit->execute(); + } + + /** + * @covers PHPUnit::execute + * @covers PHPUnit::runConfigFile + */ + public function testExecute_CallsExecuteCommandManyTimesWhenGivenArrayConfig() + { + chdir('/'); + + $this->loadPhpUnitWithOptions( + array( + 'config' => array(0, 1) + ) + ); + + $this->mockCiBuilder->expects($this->at(0))->method("executeCommand"); + $this->mockCiBuilder->expects($this->at(1))->method("executeCommand"); + + $returnValue = $this->testedPhpUnit->execute(); + } } \ No newline at end of file