From 0bcf89e82a3dbdd29220e4e2afefcd5977621173 Mon Sep 17 00:00:00 2001 From: Michael Squires Date: Thu, 27 Dec 2012 20:57:55 -0500 Subject: [PATCH] Issue #33 - Cleanup. Additional exception. --- .travis.yml | 2 +- composer.json | 7 ++ library/Phue/Command/Authenticate.php | 4 +- library/Phue/Command/CreateGroup.php | 4 +- library/Phue/Command/CreateSchedule.php | 6 +- library/Phue/Command/DeleteGroup.php | 4 +- library/Phue/Command/DeleteSchedule.php | 4 +- library/Phue/Command/SetBridgeConfig.php | 4 +- library/Phue/Command/SetGroupAction.php | 4 +- library/Phue/Command/SetGroupConfig.php | 4 +- library/Phue/Command/SetLightName.php | 4 +- library/Phue/Command/SetLightState.php | 4 +- library/Phue/Command/StartLightScan.php | 4 +- .../Exception/InvalidBodyException.php | 4 +- .../Exception/InvalidParameterException.php | 4 +- .../Exception/InvalidValueException.php | 4 +- .../Transport/Exception/MethodException.php | 4 +- .../ParameterUnavailableException.php | 4 +- .../ParameterUnmodifiableException.php | 23 ++++++ .../Transport/Exception/ResourceException.php | 4 +- library/Phue/Transport/Http.php | 24 +------ tests/PhueTest/Command/CreateGroupTest.php | 10 +-- tests/PhueTest/Command/CreateScheduleTest.php | 36 ++++++---- tests/PhueTest/Command/IsAuthorizedTest.php | 8 ++- tests/PhueTest/Command/SetGroupActionTest.php | 8 ++- tests/PhueTest/Command/SetGroupConfigTest.php | 10 +-- tests/PhueTest/Command/SetLightStateTest.php | 72 ++++++++++++------- tests/PhueTest/Transport/HttpTest.php | 19 +---- tests/{codesniffer.xml => phpcs.xml} | 0 29 files changed, 164 insertions(+), 125 deletions(-) create mode 100644 library/Phue/Transport/Exception/ParameterUnmodifiableException.php rename tests/{codesniffer.xml => phpcs.xml} (100%) diff --git a/.travis.yml b/.travis.yml index 674d7a7..5f38280 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ before_install: - composer install --dev script: - - ./vendor/bin/phpcs --standard=tests/codesniffer.xml library/ + - ./vendor/bin/phpcs --standard=tests/phpcs.xml library/ - ./vendor/bin/phpunit --configuration=tests notifications: diff --git a/composer.json b/composer.json index 5cb240d..fe0ce97 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,13 @@ ], "homepage": "http://github.com/sqmk/phue", "license": "BSD-3-Clause", + "authors": [ + { + "name": "Michael Squires", + "email": "sqmk@php.net", + "role": "lead" + } + ], "require": { "php": "5.4.*" }, diff --git a/library/Phue/Command/Authenticate.php b/library/Phue/Command/Authenticate.php index 54cfc4c..b77d26f 100644 --- a/library/Phue/Command/Authenticate.php +++ b/library/Phue/Command/Authenticate.php @@ -11,7 +11,7 @@ namespace Phue\Command; use Phue\Client; -use Phue\Transport\Http; +use Phue\Transport\TransportInterface; use Phue\Command\CommandInterface; /** @@ -34,7 +34,7 @@ public function send(Client $client) // Get response $response = $client->getTransport()->sendRequest( '', - Http::METHOD_POST, + TransportInterface::METHOD_POST, $this->buildRequestData($client) ); diff --git a/library/Phue/Command/CreateGroup.php b/library/Phue/Command/CreateGroup.php index 5e67e3a..fccfebc 100644 --- a/library/Phue/Command/CreateGroup.php +++ b/library/Phue/Command/CreateGroup.php @@ -11,7 +11,7 @@ namespace Phue\Command; use Phue\Client; -use Phue\Transport\Http; +use Phue\Transport\TransportInterface; use Phue\Command\CommandInterface; /** @@ -92,7 +92,7 @@ public function send(Client $client) { $response = $client->getTransport()->sendRequest( "{$client->getUsername()}/groups", - Http::METHOD_POST, + TransportInterface::METHOD_POST, (object) [ 'name' => $this->name, 'lights' => $this->lights diff --git a/library/Phue/Command/CreateSchedule.php b/library/Phue/Command/CreateSchedule.php index 191ca13..9ee7956 100644 --- a/library/Phue/Command/CreateSchedule.php +++ b/library/Phue/Command/CreateSchedule.php @@ -11,7 +11,7 @@ namespace Phue\Command; use Phue\Client; -use Phue\Transport\Http; +use Phue\Transport\TransportInterface; use Phue\Command\CommandInterface; use Phue\Command\SchedulableInterface; @@ -70,6 +70,8 @@ public function __construct( $time !== null && $this->time($time); $command !== null && $this->command($command); + // Copy description + $this->description = $this->name; } /** @@ -141,7 +143,7 @@ public function send(Client $client) { $scheduleId = $client->getTransport()->sendRequest( "{$client->getUsername()}/schedules", - Http::METHOD_POST, + TransportInterface::METHOD_POST, (object) [ 'name' => $this->name, 'description' => $this->description, diff --git a/library/Phue/Command/DeleteGroup.php b/library/Phue/Command/DeleteGroup.php index 170b679..99db65d 100644 --- a/library/Phue/Command/DeleteGroup.php +++ b/library/Phue/Command/DeleteGroup.php @@ -11,7 +11,7 @@ namespace Phue\Command; use Phue\Client; -use Phue\Transport\Http; +use Phue\Transport\TransportInterface; use Phue\Command\CommandInterface; /** @@ -50,7 +50,7 @@ public function send(Client $client) { $client->getTransport()->sendRequest( "{$client->getUsername()}/groups/{$this->groupId}", - Http::METHOD_DELETE + TransportInterface::METHOD_DELETE ); } } diff --git a/library/Phue/Command/DeleteSchedule.php b/library/Phue/Command/DeleteSchedule.php index 879d1fe..e38ebc9 100644 --- a/library/Phue/Command/DeleteSchedule.php +++ b/library/Phue/Command/DeleteSchedule.php @@ -11,7 +11,7 @@ namespace Phue\Command; use Phue\Client; -use Phue\Transport\Http; +use Phue\Transport\TransportInterface; use Phue\Command\CommandInterface; /** @@ -50,7 +50,7 @@ public function send(Client $client) { $client->getTransport()->sendRequest( "{$client->getUsername()}/schedules/{$this->scheduleId}", - Http::METHOD_DELETE + TransportInterface::METHOD_DELETE ); } } diff --git a/library/Phue/Command/SetBridgeConfig.php b/library/Phue/Command/SetBridgeConfig.php index 8a40c96..f7ac294 100644 --- a/library/Phue/Command/SetBridgeConfig.php +++ b/library/Phue/Command/SetBridgeConfig.php @@ -11,7 +11,7 @@ namespace Phue\Command; use Phue\Client; -use Phue\Transport\Http; +use Phue\Transport\TransportInterface; use Phue\Command\CommandInterface; /** @@ -50,7 +50,7 @@ public function send(Client $client) { $client->getTransport()->sendRequest( "{$client->getUsername()}/config", - Http::METHOD_PUT, + TransportInterface::METHOD_PUT, (object) $this->config ); } diff --git a/library/Phue/Command/SetGroupAction.php b/library/Phue/Command/SetGroupAction.php index 97a3013..a633c65 100644 --- a/library/Phue/Command/SetGroupAction.php +++ b/library/Phue/Command/SetGroupAction.php @@ -11,7 +11,7 @@ namespace Phue\Command; use Phue\Client; -use Phue\Transport\Http; +use Phue\Transport\TransportInterface; use Phue\Command\SetLightState; use Phue\Command\SchedulableInterface; @@ -72,7 +72,7 @@ public function getSchedulableParams(Client $client) { return [ 'address' => "{$client->getUsername()}/groups/{$this->groupId}/action", - 'method' => Http::METHOD_PUT, + 'method' => TransportInterface::METHOD_PUT, 'body' => (object) $this->params ]; } diff --git a/library/Phue/Command/SetGroupConfig.php b/library/Phue/Command/SetGroupConfig.php index 72a1995..d4bc921 100644 --- a/library/Phue/Command/SetGroupConfig.php +++ b/library/Phue/Command/SetGroupConfig.php @@ -11,7 +11,7 @@ namespace Phue\Command; use Phue\Client; -use Phue\Transport\Http; +use Phue\Transport\TransportInterface; use Phue\Command\CommandInterface; /** @@ -91,7 +91,7 @@ public function send(Client $client) { $client->getTransport()->sendRequest( "{$client->getUsername()}/groups/{$this->groupId}", - Http::METHOD_PUT, + TransportInterface::METHOD_PUT, (object) $this->params ); } diff --git a/library/Phue/Command/SetLightName.php b/library/Phue/Command/SetLightName.php index 12dce30..11b44c6 100644 --- a/library/Phue/Command/SetLightName.php +++ b/library/Phue/Command/SetLightName.php @@ -12,7 +12,7 @@ use Phue\Client; use Phue\Light; -use Phue\Transport\Http; +use Phue\Transport\TransportInterface; use Phue\Command\CommandInterface; /** @@ -60,7 +60,7 @@ public function send(Client $client) { $client->getTransport()->sendRequest( "{$client->getUsername()}/lights/{$this->lightId}", - Http::METHOD_PUT, + TransportInterface::METHOD_PUT, (object) [ 'name' => $this->name ] diff --git a/library/Phue/Command/SetLightState.php b/library/Phue/Command/SetLightState.php index fd55ddf..e9e2637 100644 --- a/library/Phue/Command/SetLightState.php +++ b/library/Phue/Command/SetLightState.php @@ -11,7 +11,7 @@ namespace Phue\Command; use Phue\Client; -use Phue\Transport\Http; +use Phue\Transport\TransportInterface; use Phue\Command\CommandInterface; use Phue\Command\SchedulableInterface; @@ -327,7 +327,7 @@ public function getSchedulableParams(Client $client) { return [ 'address' => "{$client->getUsername()}/lights/{$this->lightId}/state", - 'method' => Http::METHOD_PUT, + 'method' => TransportInterface::METHOD_PUT, 'body' => (object) $this->params ]; } diff --git a/library/Phue/Command/StartLightScan.php b/library/Phue/Command/StartLightScan.php index ef224b6..f4d2656 100644 --- a/library/Phue/Command/StartLightScan.php +++ b/library/Phue/Command/StartLightScan.php @@ -11,7 +11,7 @@ namespace Phue\Command; use Phue\Client; -use Phue\Transport\Http; +use Phue\Transport\TransportInterface; use Phue\Command\CommandInterface; /** @@ -34,7 +34,7 @@ public function send(Client $client) // Get response $response = $client->getTransport()->sendRequest( "{$client->getUsername()}/lights", - Http::METHOD_POST + TransportInterface::METHOD_POST ); return $response; diff --git a/library/Phue/Transport/Exception/InvalidBodyException.php b/library/Phue/Transport/Exception/InvalidBodyException.php index 6d35553..3706e9f 100644 --- a/library/Phue/Transport/Exception/InvalidBodyException.php +++ b/library/Phue/Transport/Exception/InvalidBodyException.php @@ -10,12 +10,14 @@ namespace Phue\Transport\Exception; +use Phue\Transport\Exception\BridgeException; + /** * Invalid body exception * * @category Phue * @package Phue */ -class InvalidBodyException extends \Exception +class InvalidBodyException extends BridgeException { } diff --git a/library/Phue/Transport/Exception/InvalidParameterException.php b/library/Phue/Transport/Exception/InvalidParameterException.php index b85c2e6..50c8cf7 100644 --- a/library/Phue/Transport/Exception/InvalidParameterException.php +++ b/library/Phue/Transport/Exception/InvalidParameterException.php @@ -10,12 +10,14 @@ namespace Phue\Transport\Exception; +use Phue\Transport\Exception\BridgeException; + /** * Invalid parameter exception * * @category Phue * @package Phue */ -class InvalidParameterException extends \Exception +class InvalidParameterException extends BridgeException { } diff --git a/library/Phue/Transport/Exception/InvalidValueException.php b/library/Phue/Transport/Exception/InvalidValueException.php index 340cc7c..40fe21f 100644 --- a/library/Phue/Transport/Exception/InvalidValueException.php +++ b/library/Phue/Transport/Exception/InvalidValueException.php @@ -10,12 +10,14 @@ namespace Phue\Transport\Exception; +use Phue\Transport\Exception\BridgeException; + /** * Invalid value exception * * @category Phue * @package Phue */ -class InvalidValueException extends \Exception +class InvalidValueException extends BridgeException { } diff --git a/library/Phue/Transport/Exception/MethodException.php b/library/Phue/Transport/Exception/MethodException.php index 12d4a4e..ae9ae07 100644 --- a/library/Phue/Transport/Exception/MethodException.php +++ b/library/Phue/Transport/Exception/MethodException.php @@ -10,12 +10,14 @@ namespace Phue\Transport\Exception; +use Phue\Transport\Exception\BridgeException; + /** * Method exception * * @category Phue * @package Phue */ -class MethodException extends \Exception +class MethodException extends BridgeException { } diff --git a/library/Phue/Transport/Exception/ParameterUnavailableException.php b/library/Phue/Transport/Exception/ParameterUnavailableException.php index 4304a57..b6a67e9 100644 --- a/library/Phue/Transport/Exception/ParameterUnavailableException.php +++ b/library/Phue/Transport/Exception/ParameterUnavailableException.php @@ -10,12 +10,14 @@ namespace Phue\Transport\Exception; +use Phue\Transport\Exception\BridgeException; + /** * Parameter unavailable exception * * @category Phue * @package Phue */ -class ParameterUnavailableException extends \Exception +class ParameterUnavailableException extends BridgeException { } diff --git a/library/Phue/Transport/Exception/ParameterUnmodifiableException.php b/library/Phue/Transport/Exception/ParameterUnmodifiableException.php new file mode 100644 index 0000000..f053e2a --- /dev/null +++ b/library/Phue/Transport/Exception/ParameterUnmodifiableException.php @@ -0,0 +1,23 @@ + + * @copyright Copyright (c) 2012 Michael K. Squires + * @license http://github.com/sqmk/Phue/wiki/License + * @package Phue + */ + +namespace Phue\Transport\Exception; + +use Phue\Transport\Exception\BridgeException; + +/** + * Parameter unmodifiable exception + * + * @category Phue + * @package Phue + */ +class ParameterUnmodifiableException extends BridgeException +{ +} diff --git a/library/Phue/Transport/Exception/ResourceException.php b/library/Phue/Transport/Exception/ResourceException.php index 037ef17..b87ba11 100644 --- a/library/Phue/Transport/Exception/ResourceException.php +++ b/library/Phue/Transport/Exception/ResourceException.php @@ -10,12 +10,14 @@ namespace Phue\Transport\Exception; +use Phue\Transport\Exception\BridgeException; + /** * Resource exception * * @category Phue * @package Phue */ -class ResourceException extends \Exception +class ResourceException extends BridgeException { } diff --git a/library/Phue/Transport/Http.php b/library/Phue/Transport/Http.php index a453953..2401204 100644 --- a/library/Phue/Transport/Http.php +++ b/library/Phue/Transport/Http.php @@ -54,6 +54,7 @@ class Http implements TransportInterface 6 => 'Phue\Transport\Exception\ParameterUnavailableException', 7 => 'Phue\Transport\Exception\InvalidValueException', 101 => 'Phue\Transport\Exception\LinkButtonException', + 201 => 'Phue\Transport\Exception\ParameterUnmodifiableException', 301 => 'Phue\Transport\Exception\GroupTableFullException', 901 => 'Phue\Transport\Exception\ThrottleException', ]; @@ -110,7 +111,7 @@ public function setAdapter(AdapterInterface $adapter) public function sendRequest($address, $method = self::METHOD_GET, \stdClass $body = null) { // Build request url - $url = $this->buildRequestUrl($address, true); + $url = "http://{$this->client->getHost()}/api/{$address}"; // Open connection $this->getAdapter()->open(); @@ -152,27 +153,6 @@ public function sendRequest($address, $method = self::METHOD_GET, \stdClass $bod return $jsonResults; } - /** - * Build request URL - * - * @param string $path Request path - * @param bool $includeHost Include host in path - * - * @return string Request URL - */ - public function buildRequestUrl($path, $includeHost = false) - { - // Start with full path - $fullPath = "/api/{$path}"; - - // Include host if necessary - if ($includeHost) { - $fullPath = "http://{$this->client->getHost()}" . $fullPath; - } - - return $fullPath; - } - /** * Get exception by type * diff --git a/tests/PhueTest/Command/CreateGroupTest.php b/tests/PhueTest/Command/CreateGroupTest.php index 594f5b9..63ca801 100644 --- a/tests/PhueTest/Command/CreateGroupTest.php +++ b/tests/PhueTest/Command/CreateGroupTest.php @@ -111,10 +111,12 @@ public function testSend() ->with( $this->equalTo("{$this->mockClient->getUsername()}/groups"), $this->equalTo(TransportInterface::METHOD_POST), - $this->equalTo((object) [ - 'name' => 'Dummy', - 'lights' => [2, 3] - ]) + $this->equalTo( + (object) [ + 'name' => 'Dummy', + 'lights' => [2, 3] + ] + ) ) ->will($this->returnValue((object)['id' => '/path/5'])); diff --git a/tests/PhueTest/Command/CreateScheduleTest.php b/tests/PhueTest/Command/CreateScheduleTest.php index c2d93e5..5e7ca69 100644 --- a/tests/PhueTest/Command/CreateScheduleTest.php +++ b/tests/PhueTest/Command/CreateScheduleTest.php @@ -64,11 +64,15 @@ public function setUp() // Stub command's getSchedulableParams method $this->mockCommand->expects($this->any()) ->method('getSchedulableParams') - ->will($this->returnValue([ - 'address' => '/api/endpoint', - 'method' => 'POST', - 'body' => 'Dummy' - ])); + ->will( + $this->returnValue( + [ + 'address' => '/api/endpoint', + 'method' => 'POST', + 'body' => 'Dummy' + ] + ) + ); } /** @@ -156,7 +160,7 @@ public function testCommand() // Ensure properties are set properly $this->assertAttributeEquals( - $this->mockCommand, + $this->mockCommand, 'command', $command ); @@ -182,16 +186,18 @@ public function testSend() ->with( $this->equalTo("{$this->mockClient->getUsername()}/schedules"), $this->equalTo(TransportInterface::METHOD_POST), - $this->equalTo((object) [ - 'name' => 'Dummy!', - 'description' => 'Description!', - 'time' => '2012-12-30T10:11:12', - 'command' => [ - 'method' => TransportInterface::METHOD_POST, - 'address' => "/api/endpoint", - 'body' => "Dummy" + $this->equalTo( + (object) [ + 'name' => 'Dummy!', + 'description' => 'Description!', + 'time' => '2012-12-30T10:11:12', + 'command' => [ + 'method' => TransportInterface::METHOD_POST, + 'address' => "/api/endpoint", + 'body' => "Dummy" + ] ] - ]) + ) ) ->will($this->returnValue(4)); diff --git a/tests/PhueTest/Command/IsAuthorizedTest.php b/tests/PhueTest/Command/IsAuthorizedTest.php index 1b52505..b47e417 100644 --- a/tests/PhueTest/Command/IsAuthorizedTest.php +++ b/tests/PhueTest/Command/IsAuthorizedTest.php @@ -82,9 +82,11 @@ public function testIsNotAuthorized() $this->mockTransport->expects($this->once()) ->method('sendRequest') ->with($this->equalTo($this->mockClient->getUsername())) - ->will($this->throwException( - $this->getMock('\Phue\Transport\Exception\AuthorizationException') - )); + ->will( + $this->throwException( + $this->getMock('\Phue\Transport\Exception\AuthorizationException') + ) + ); $this->assertFalse( (new IsAuthorized)->send($this->mockClient) diff --git a/tests/PhueTest/Command/SetGroupActionTest.php b/tests/PhueTest/Command/SetGroupActionTest.php index ecdee05..929aa3f 100644 --- a/tests/PhueTest/Command/SetGroupActionTest.php +++ b/tests/PhueTest/Command/SetGroupActionTest.php @@ -72,9 +72,11 @@ public function testSend() $setGroupActionCmd = new SetGroupAction($this->mockGroup); // Set expected payload - $this->stubTransportSendRequestWithPayload((object) [ - 'ct' => '300' - ]); + $this->stubTransportSendRequestWithPayload( + (object) [ + 'ct' => '300' + ] + ); // Change color temp and set state $setGroupActionCmd->colorTemp(300) diff --git a/tests/PhueTest/Command/SetGroupConfigTest.php b/tests/PhueTest/Command/SetGroupConfigTest.php index 4193993..d1bac68 100644 --- a/tests/PhueTest/Command/SetGroupConfigTest.php +++ b/tests/PhueTest/Command/SetGroupConfigTest.php @@ -74,10 +74,12 @@ public function testSend() $setGroupConfigCmd = new SetGroupConfig($this->mockGroup); // Set expected payload - $this->stubTransportSendRequestWithPayload((object) [ - 'name' => 'Dummy!', - 'lights' => [3] - ]); + $this->stubTransportSendRequestWithPayload( + (object) [ + 'name' => 'Dummy!', + 'lights' => [3] + ] + ); // Change name and lights $setGroupConfigCmd->name('Dummy!') diff --git a/tests/PhueTest/Command/SetLightStateTest.php b/tests/PhueTest/Command/SetLightStateTest.php index fa460fd..7397659 100644 --- a/tests/PhueTest/Command/SetLightStateTest.php +++ b/tests/PhueTest/Command/SetLightStateTest.php @@ -74,9 +74,11 @@ public function testOnSend($state) $command = new SetLightState($this->mockLight); // Set expected payload - $this->stubTransportSendRequestWithPayload((object) [ - 'on' => $state - ]); + $this->stubTransportSendRequestWithPayload( + (object) [ + 'on' => $state + ] + ); // Ensure instance is returned $this->assertEquals( @@ -116,9 +118,11 @@ public function testBrightnessSend($brightness) $command = new SetLightState($this->mockLight); // Set expected payload - $this->stubTransportSendRequestWithPayload((object) [ - 'bri' => $brightness - ]); + $this->stubTransportSendRequestWithPayload( + (object) [ + 'bri' => $brightness + ] + ); // Ensure instance is returned $this->assertEquals( @@ -156,9 +160,11 @@ public function testHueSend($value) $command = new SetLightState($this->mockLight); // Set expected payload - $this->stubTransportSendRequestWithPayload((object) [ - 'hue' => $value - ]); + $this->stubTransportSendRequestWithPayload( + (object) [ + 'hue' => $value + ] + ); // Ensure instance is returned $this->assertEquals( @@ -196,9 +202,11 @@ public function testSaturationSend($value) $command = new SetLightState($this->mockLight); // Set expected payload - $this->stubTransportSendRequestWithPayload((object) [ - 'sat' => $value - ]); + $this->stubTransportSendRequestWithPayload( + (object) [ + 'sat' => $value + ] + ); // Ensure instance is returned $this->assertEquals( @@ -238,9 +246,11 @@ public function testXYSend($x, $y) $command = new SetLightState($this->mockLight); // Set expected payload - $this->stubTransportSendRequestWithPayload((object) [ - 'xy' => [$x, $y] - ]); + $this->stubTransportSendRequestWithPayload( + (object) [ + 'xy' => [$x, $y] + ] + ); // Ensure instance is returned $this->assertEquals( @@ -280,9 +290,11 @@ public function testColorTempSend($temp) $command = new SetLightState($this->mockLight); // Set expected payload - $this->stubTransportSendRequestWithPayload((object) [ - 'ct' => $temp - ]); + $this->stubTransportSendRequestWithPayload( + (object) [ + 'ct' => $temp + ] + ); // Ensure instance is returned $this->assertEquals( @@ -336,9 +348,11 @@ public function testAlertSend($mode) $command = new SetLightState($this->mockLight); // Set expected payload - $this->stubTransportSendRequestWithPayload((object) [ - 'alert' => $mode - ]); + $this->stubTransportSendRequestWithPayload( + (object) [ + 'alert' => $mode + ] + ); // Ensure instance is returned $this->assertEquals( @@ -376,9 +390,11 @@ public function testTransitionTimeSend($time) $command = new SetLightState($this->mockLight); // Set expected payload - $this->stubTransportSendRequestWithPayload((object) [ - 'transitiontime' => $time * 10 - ]); + $this->stubTransportSendRequestWithPayload( + (object) [ + 'transitiontime' => $time * 10 + ] + ); // Ensure instance is returned $this->assertEquals( @@ -402,9 +418,11 @@ public function testSend() $setLightStateCmd = new SetLightState($this->mockLight); // Set expected payload - $this->stubTransportSendRequestWithPayload((object) [ - 'alert' => 'select' - ]); + $this->stubTransportSendRequestWithPayload( + (object) [ + 'alert' => 'select' + ] + ); // Change alert and set state $setLightStateCmd->alert('select') diff --git a/tests/PhueTest/Transport/HttpTest.php b/tests/PhueTest/Transport/HttpTest.php index d295843..ef0cfbd 100644 --- a/tests/PhueTest/Transport/HttpTest.php +++ b/tests/PhueTest/Transport/HttpTest.php @@ -202,24 +202,6 @@ public function testSendRequestSuccess() ); } - /** - * Test: Build request URL - * - * @covers Phue\Transport\Http::buildRequestUrl - */ - public function testBuildRequestUrl() - { - $this->assertEquals( - $this->transport->buildRequestUrl('dummy', true), - "http://{$this->mockClient->getHost()}/api/dummy" - ); - - $this->assertEquals( - $this->transport->buildRequestUrl('dummy'), - "/api/dummy" - ); - } - /** * Test: Throw exception by type * @@ -251,6 +233,7 @@ public function providerErrorTypes() [6, 'Phue\Transport\Exception\ParameterUnavailableException'], [7, 'Phue\Transport\Exception\InvalidValueException'], [101, 'Phue\Transport\Exception\LinkButtonException'], + [201, 'Phue\Transport\Exception\ParameterUnmodifiableException'], [301, 'Phue\Transport\Exception\GroupTableFullException'], [901, 'Phue\Transport\Exception\ThrottleException'], [-1, 'Phue\Transport\Exception\BridgeException'], diff --git a/tests/codesniffer.xml b/tests/phpcs.xml similarity index 100% rename from tests/codesniffer.xml rename to tests/phpcs.xml