From cb8d1a02523f3cfa374d629813eeab3b989cb806 Mon Sep 17 00:00:00 2001 From: Maksym Novozhylov Date: Mon, 16 Jul 2018 10:35:29 +0200 Subject: [PATCH 1/3] v1.4.0 changes --- CHANGES.md | 3 ++ composer.json | 4 +-- .../API/Routers/Reports/Finance/Accounts.php | 17 ---------- .../API/Routers/Reports/Finance/Billings.php | 34 ------------------- .../API/Routers/Reports/Finance/Earnings.php | 34 ------------------- .../Routers/Reports/Finance/AccountsTest.php | 11 ------ .../Routers/Reports/Finance/BillingsTest.php | 22 ------------ .../Routers/Reports/Finance/EarningsTest.php | 22 ------------ 8 files changed, 5 insertions(+), 142 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 225ede4..cba01ab 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,8 @@ # Release History +## 1.4.0 +* Stop supporting some Reports API according to announce from Thursday, 2018-06-28 + ## 1.3.1 * Fixed non-working getByContract from Workdays API diff --git a/composer.json b/composer.json index 9fd285e..996cb4a 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,11 @@ { "name": "upwork/php-upwork", "description": "PHP bindings for Upwork API", - "version": "v1.3.0", + "version": "v1.4.0", "type": "library", "keywords": ["upwork", "php", "api"], "homepage": "http://www.upwork.com", - "time": "2018-05-24", + "time": "2018-07-24", "license": "Apache-2.0", "authors": [ { diff --git a/src/Upwork/API/Routers/Reports/Finance/Accounts.php b/src/Upwork/API/Routers/Reports/Finance/Accounts.php index 997d731..caf35f0 100644 --- a/src/Upwork/API/Routers/Reports/Finance/Accounts.php +++ b/src/Upwork/API/Routers/Reports/Finance/Accounts.php @@ -42,23 +42,6 @@ public function __construct(ApiClient $client) parent::$_epoint = self::ENTRY_POINT; } - /** - * Generate Financial Reports for an owned Account - * - * @param integer $freelancerReference Freelancer reference - * @param array $params Parameters - * @return object - */ - public function getOwned($freelancerReference, $params) - { - ApiDebug::p(__FUNCTION__); - - $report = $this->_client->get('/finreports/v2/financial_account_owner/' . $freelancerReference, $params); - ApiDebug::p('found report info', $report); - - return $report; - } - /** * Generate Financial Reports for a Specific Account * diff --git a/src/Upwork/API/Routers/Reports/Finance/Billings.php b/src/Upwork/API/Routers/Reports/Finance/Billings.php index 746b335..967fef4 100644 --- a/src/Upwork/API/Routers/Reports/Finance/Billings.php +++ b/src/Upwork/API/Routers/Reports/Finance/Billings.php @@ -59,40 +59,6 @@ public function getByFreelancer($freelancerReference, $params) return $report; } - /** - * Generate Billing Reports for a Specific Freelancer's Team - * - * @param integer $freelancerTeamReference Freelancer team reference - * @param array $params Parameters - * @return object - */ - public function getByFreelancersTeam($freelancerTeamReference, $params) - { - ApiDebug::p(__FUNCTION__); - - $report = $this->_client->get('/finreports/v2/provider_teams/' . $freelancerTeamReference . '/billings', $params); - ApiDebug::p('found report info', $report); - - return $report; - } - - /** - * Generate Billing Reports for a Specific Freelancer's Company - * - * @param integer $freelancerCompanyReference Freelancer company reference - * @param array $params Parameters - * @return object - */ - public function getByFreelancersCompany($freelancerCompanyReference, $params) - { - ApiDebug::p(__FUNCTION__); - - $report = $this->_client->get('/finreports/v2/provider_companies/' . $freelancerCompanyReference . '/billings', $params); - ApiDebug::p('found report info', $report); - - return $report; - } - /** * Generate Billing Reports for a Specific Buyer's Team * diff --git a/src/Upwork/API/Routers/Reports/Finance/Earnings.php b/src/Upwork/API/Routers/Reports/Finance/Earnings.php index 55ae9ac..7f1a72e 100644 --- a/src/Upwork/API/Routers/Reports/Finance/Earnings.php +++ b/src/Upwork/API/Routers/Reports/Finance/Earnings.php @@ -59,40 +59,6 @@ public function getByFreelancer($freelancerReference, $params) return $report; } - /** - * Generate Earning Reports for a Specific Freelancer's Team - * - * @param integer $freelancerTeamReference Freelancer team reference - * @param array $params Parameters - * @return object - */ - public function getByFreelancersTeam($freelancerTeamReference, $params) - { - ApiDebug::p(__FUNCTION__); - - $report = $this->_client->get('/finreports/v2/provider_teams/' . $freelancerTeamReference . '/earnings', $params); - ApiDebug::p('found report info', $report); - - return $report; - } - - /** - * Generate Earning Reports for a Specific Freelancer's Company - * - * @param integer $freelancerCompanyReference Freelancer company reference - * @param array $params Parameters - * @return object - */ - public function getByFreelancersCompany($freelancerCompanyReference, $params) - { - ApiDebug::p(__FUNCTION__); - - $report = $this->_client->get('/finreports/v2/provider_companies/' . $freelancerCompanyReference . '/earnings', $params); - ApiDebug::p('found report info', $report); - - return $report; - } - /** * Generate Earning Reports for a Specific Buyer's Team * diff --git a/tests/Upwork/API/Routers/Reports/Finance/AccountsTest.php b/tests/Upwork/API/Routers/Reports/Finance/AccountsTest.php index 5b7ff4d..24c8a2f 100644 --- a/tests/Upwork/API/Routers/Reports/Finance/AccountsTest.php +++ b/tests/Upwork/API/Routers/Reports/Finance/AccountsTest.php @@ -15,17 +15,6 @@ public function setUp() parent::setUp(); } - /** - * @test - */ - public function testGetOwned() - { - $router = new \Upwork\API\Routers\Reports\Finance\Accounts($this->_client); - $response = $router->getOwned('12345', array()); - - $this->_checkResponse($response); - } - /** * @test */ diff --git a/tests/Upwork/API/Routers/Reports/Finance/BillingsTest.php b/tests/Upwork/API/Routers/Reports/Finance/BillingsTest.php index 426bda3..9aa0808 100644 --- a/tests/Upwork/API/Routers/Reports/Finance/BillingsTest.php +++ b/tests/Upwork/API/Routers/Reports/Finance/BillingsTest.php @@ -26,28 +26,6 @@ public function testGetByFreelancer() $this->_checkResponse($response); } - /** - * @test - */ - public function testGetByFreelancersTeam() - { - $router = new \Upwork\API\Routers\Reports\Finance\Billings($this->_client); - $response = $router->getByFreelancersTeam('12345', array()); - - $this->_checkResponse($response); - } - - /** - * @test - */ - public function testGetByFreelancersCompany() - { - $router = new \Upwork\API\Routers\Reports\Finance\Billings($this->_client); - $response = $router->getByFreelancersCompany('12345', array()); - - $this->_checkResponse($response); - } - /** * @test */ diff --git a/tests/Upwork/API/Routers/Reports/Finance/EarningsTest.php b/tests/Upwork/API/Routers/Reports/Finance/EarningsTest.php index 9cfcfc0..2488700 100644 --- a/tests/Upwork/API/Routers/Reports/Finance/EarningsTest.php +++ b/tests/Upwork/API/Routers/Reports/Finance/EarningsTest.php @@ -26,28 +26,6 @@ public function testGetByFreelancer() $this->_checkResponse($response); } - /** - * @test - */ - public function testGetByFreelancersTeam() - { - $router = new \Upwork\API\Routers\Reports\Finance\Earnings($this->_client); - $response = $router->getByFreelancersTeam('12345', array()); - - $this->_checkResponse($response); - } - - /** - * @test - */ - public function testGetByFreelancersCompany() - { - $router = new \Upwork\API\Routers\Reports\Finance\Earnings($this->_client); - $response = $router->getByFreelancersCompany('12345', array()); - - $this->_checkResponse($response); - } - /** * @test */ From 8bf02f93da901eb6095e48b08293a28b64f3a2f2 Mon Sep 17 00:00:00 2001 From: Maksym Novozhylov Date: Fri, 18 Sep 2020 15:53:17 +0200 Subject: [PATCH 2/3] Changes for v1.4.0 --- .travis.yml | 5 ++- CHANGES.md | 12 ++++++ composer.json | 4 +- src/Upwork/API/Routers/Hr/Milestones.php | 2 +- src/Upwork/API/Routers/Messages.php | 18 ++++++++ src/Upwork/API/Routers/Workdiary.php | 2 +- tests/Upwork/API/ApiExceptionTest.php | 4 +- .../API/AuthTypes/AbstractOAuthTest.php | 5 ++- tests/Upwork/API/ClientTest.php | 42 +++++++++++++------ tests/Upwork/API/ConfigTest.php | 10 +++-- tests/Upwork/API/DebugTest.php | 6 +-- tests/Upwork/API/Interfaces/ClientTest.php | 4 +- .../API/Routers/Activities/EngagementTest.php | 2 +- .../API/Routers/Activities/TeamTest.php | 2 +- tests/Upwork/API/Routers/AuthTest.php | 2 +- tests/Upwork/API/Routers/CommonTestRouter.php | 31 ++++++++++---- .../API/Routers/Freelancers/ProfileTest.php | 4 +- .../API/Routers/Freelancers/SearchTest.php | 2 +- .../Routers/Hr/Clients/ApplicationsTest.php | 2 +- .../API/Routers/Hr/Clients/OffersTest.php | 2 +- tests/Upwork/API/Routers/Hr/ContractsTest.php | 2 +- ...ngagamentsTest.php => EngagementsTest.php} | 2 +- .../Hr/Freelancers/ApplicationsTest.php | 2 +- .../API/Routers/Hr/Freelancers/OffersTest.php | 2 +- .../Upwork/API/Routers/Hr/InterviewsTest.php | 2 +- tests/Upwork/API/Routers/Hr/JobsTest.php | 2 +- .../Upwork/API/Routers/Hr/MilestonesTest.php | 4 +- tests/Upwork/API/Routers/Hr/RolesTest.php | 2 +- .../Upwork/API/Routers/Hr/SubmissionsTest.php | 2 +- tests/Upwork/API/Routers/Jobs/ProfileTest.php | 4 +- tests/Upwork/API/Routers/Jobs/SearchTest.php | 2 +- tests/Upwork/API/Routers/MessagesTest.php | 15 ++++++- tests/Upwork/API/Routers/MetadataTest.php | 2 +- .../Routers/Organization/CompaniesTest.php | 2 +- .../API/Routers/Organization/TeamsTest.php | 2 +- .../API/Routers/Organization/UsersTest.php | 2 +- tests/Upwork/API/Routers/PaymentsTest.php | 2 +- .../Routers/Reports/Finance/AccountsTest.php | 2 +- .../Routers/Reports/Finance/BillingsTest.php | 2 +- .../Routers/Reports/Finance/EarningsTest.php | 2 +- tests/Upwork/API/Routers/Reports/TimeTest.php | 2 +- tests/Upwork/API/Routers/SnapshotTest.php | 2 +- tests/Upwork/API/Routers/WorkdaysTest.php | 2 +- tests/Upwork/API/Routers/WorkdiaryTest.php | 8 ++-- tests/Upwork/API/UtilsTest.php | 3 +- 45 files changed, 159 insertions(+), 76 deletions(-) rename tests/Upwork/API/Routers/Hr/{EngagamentsTest.php => EngagementsTest.php} (95%) diff --git a/.travis.yml b/.travis.yml index dcae460..6af3453 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: php php: - - "5.6" - - "5.5" + - "7.3" + - "7.4" - hhvm before_script: @@ -11,6 +11,7 @@ before_script: matrix: allow_failures: - php: hhvm + - "5.6" fast_finish: true script: ./vendor/phpunit/phpunit/phpunit.php --stderr diff --git a/CHANGES.md b/CHANGES.md index cba01ab..4da3194 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,20 @@ # Release History ## 1.4.0 +* Send Message to a Batch of Rooms API +* Workdiary::get was replaced with Workdiary::getByCompany (breaking!) +* Milestones::delete was replaced with Milestones::deleteMilestone (breaking!) +* Migrate tests +* Bug fixes * Stop supporting some Reports API according to announce from Thursday, 2018-06-28 +## 1.3.3 +* Add Room Messages API + +## 1.3.2 +* Add Specialties API +* Add Skills V2 API + ## 1.3.1 * Fixed non-working getByContract from Workdays API diff --git a/composer.json b/composer.json index 996cb4a..aa64f63 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "type": "library", "keywords": ["upwork", "php", "api"], "homepage": "http://www.upwork.com", - "time": "2018-07-24", + "time": "2020-09-09", "license": "Apache-2.0", "authors": [ { @@ -32,7 +32,7 @@ "ext-json": "*" }, "require-dev": { - "phpunit/phpunit": "3.7.*", + "phpunit/phpunit": "^9", "phpunit/php-invoker": "*" }, "autoload": { diff --git a/src/Upwork/API/Routers/Hr/Milestones.php b/src/Upwork/API/Routers/Hr/Milestones.php index 3bc15dd..a0bd94e 100644 --- a/src/Upwork/API/Routers/Hr/Milestones.php +++ b/src/Upwork/API/Routers/Hr/Milestones.php @@ -147,7 +147,7 @@ public function approve($milestoneId, $params) * @param integer $milestoneId Milestone ID * @return object */ - public function delete($milestoneId) + public function deleteMilestone($milestoneId) { ApiDebug::p(__FUNCTION__); diff --git a/src/Upwork/API/Routers/Messages.php b/src/Upwork/API/Routers/Messages.php index fb1673d..949582d 100644 --- a/src/Upwork/API/Routers/Messages.php +++ b/src/Upwork/API/Routers/Messages.php @@ -171,6 +171,24 @@ public function sendMessageToRoom($company, $roomId, $params = array()) return $response; } + /** + * Send a message to a batch of rooms + * + * @param string $company Company ID + * @param array $params List of parameters + * @access public + * @return object + */ + public function sendMessageToRooms($company, $params = array()) + { + ApiDebug::p(__FUNCTION__); + + $response = $this->_client->post('/messages/v3/' . $company . '/stories/batch', $params); + ApiDebug::p('received data', $response); + + return $response; + } + /** * Update a room settings * diff --git a/src/Upwork/API/Routers/Workdiary.php b/src/Upwork/API/Routers/Workdiary.php index 25a2687..3588d64 100644 --- a/src/Upwork/API/Routers/Workdiary.php +++ b/src/Upwork/API/Routers/Workdiary.php @@ -50,7 +50,7 @@ public function __construct(ApiClient $client) * @param array $params (Optional) Parameters * @return object */ - public function get($company, $date, $params = array()) + public function getByCompany($company, $date, $params = array()) { ApiDebug::p(__FUNCTION__); diff --git a/tests/Upwork/API/ApiExceptionTest.php b/tests/Upwork/API/ApiExceptionTest.php index 1914ce5..1d3385b 100644 --- a/tests/Upwork/API/ApiExceptionTest.php +++ b/tests/Upwork/API/ApiExceptionTest.php @@ -3,15 +3,17 @@ require __DIR__ . '/../../../vendor/autoload.php'; +use PHPUnit\Framework\TestCase; use Upwork\API\ApiException as ApiException; -class ApiExceptionTest extends \PHPUnit_Framework_TestCase +class ApiExceptionTest extends TestCase { /** * @expectedException Upwork\API\ApiException */ public function testException() { + $this->expectException(\Upwork\API\ApiException::class); throw new ApiException('test'); } } diff --git a/tests/Upwork/API/AuthTypes/AbstractOAuthTest.php b/tests/Upwork/API/AuthTypes/AbstractOAuthTest.php index 3b7b330..6b7b146 100644 --- a/tests/Upwork/API/AuthTypes/AbstractOAuthTest.php +++ b/tests/Upwork/API/AuthTypes/AbstractOAuthTest.php @@ -3,9 +3,10 @@ require __DIR__ . '/../../../../vendor/autoload.php'; +use PHPUnit\Framework\TestCase; use Upwork\API\AuthTypes\AbstractOAuth as AbstractOAuth; -class AbstractOAuthTest extends \PHPUnit_Framework_TestCase +class AbstractOAuthTest extends TestCase { /** * @test @@ -104,6 +105,7 @@ public function testSetupAccessToken() */ public function testNoKeySpecified() { + $this->expectException(\Upwork\API\ApiException::class); $stub = $this->getMockForAbstractClass( 'Upwork\API\AuthTypes\AbstractOAuth', array(null, 'secret') @@ -119,6 +121,7 @@ public function testNoKeySpecified() */ public function testNoSecretSpecified() { + $this->expectException(\Upwork\API\ApiException::class); $stub = $this->getMockForAbstractClass( 'Upwork\API\AuthTypes\AbstractOAuth', array('key', null) diff --git a/tests/Upwork/API/ClientTest.php b/tests/Upwork/API/ClientTest.php index 362ca18..d57dd07 100644 --- a/tests/Upwork/API/ClientTest.php +++ b/tests/Upwork/API/ClientTest.php @@ -3,11 +3,12 @@ require __DIR__ . '/../../../vendor/autoload.php'; +use PHPUnit\Framework\TestCase; use Upwork\API\Debug as ApiDebug; use Upwork\API\Config as ApiConfig; use Upwork\API\Client as Client; -class ClientTest extends \PHPUnit_Framework_TestCase +class ClientTest extends TestCase { /** * @test @@ -37,14 +38,13 @@ public function testGetServer() 'consumerSecret' => 'secret' ) ); - $reflection = new \ReflectionClass('Upwork\API\Client'); + $reflection = new \ReflectionClass(\Upwork\API\Client::class); $property = $reflection->getProperty('_server'); $property->setAccessible(true); $helper = new Client($config); $property->setValue($helper, new \StdClass); $server = $helper->getServer(); - $this->assertAttributeInstanceOf('StdClass', '_server', $helper); $this->assertInstanceOf('StdClass', $server); } @@ -59,12 +59,14 @@ public function testGetRequestToken() 'consumerSecret' => 'secret' ) ); - $reflection = new \ReflectionClass('Upwork\API\Client'); + $reflection = new \ReflectionClass(\Upwork\API\Client::class); $property = $reflection->getProperty('_server'); $property->setAccessible(true); $helper = new Client($config); - $stub = $this->getMock('StdClass', array('setupRequestToken')); + $stub = $this->getMockBuilder(stdClass::class) + ->setMethods(['setupRequestToken']) + ->getMock(); $stub->expects($this->any()) ->method('setupRequestToken') ->will($this->returnValue('testtoken')); @@ -85,12 +87,14 @@ public function testAuth() 'consumerSecret' => 'secret' ) ); - $reflection = new \ReflectionClass('Upwork\API\Client'); + $reflection = new \ReflectionClass(\Upwork\API\Client::class); $property = $reflection->getProperty('_server'); $property->setAccessible(true); $helper = new Client($config); - $stub = $this->getMock('StdClass', array('option', 'auth')); + $stub = $this->getMockBuilder(stdClass::class) + ->setMethods(['option', 'auth']) + ->getMock(); $stub->expects($this->any()) ->method('option') ->will($this->returnValue(true)); @@ -114,14 +118,16 @@ public function testRequest() 'consumerSecret' => 'secret' ) ); - $reflection = new \ReflectionClass('Upwork\API\Client'); + $reflection = new \ReflectionClass(\Upwork\API\Client::class); $property = $reflection->getProperty('_server'); $property->setAccessible(true); $method = $reflection->getMethod('_request'); $method->setAccessible(true); $helper = new Client($config); - $stub = $this->getMock('StdClass', array('option', 'request')); + $stub = $this->getMockBuilder(stdClass::class) + ->setMethods(['option', 'request']) + ->getMock(); $stub->expects($this->any()) ->method('option') ->will($this->returnValue(true)); @@ -134,7 +140,7 @@ public function testRequest() $response = $method->invoke($helper, 'GET', 'http://www.upwork.com/api/auth/v1/info', array()); $this->assertInstanceOf('StdClass', $response); $this->assertObjectHasAttribute('a', $response); - $this->assertInternalType('string', $response->a); + $this->assertIsString($response->a); $this->assertSame('b', $response->a); } @@ -150,9 +156,21 @@ public function testRunMethod() ) ); - $stub = $this->getMock('Upwork\API\Client', array('_request'), array($config)); + $stub = $this->getMockBuilder(\Upwork\API\Client::class) + ->enableArgumentCloning() + ->setConstructorArgs([$config]) + ->getMock(); $stub->expects($this->any()) - ->method('_request') + ->method('get') + ->will($this->returnValue('response')); + $stub->expects($this->any()) + ->method('post') + ->will($this->returnValue('response')); + $stub->expects($this->any()) + ->method('put') + ->will($this->returnValue('response')); + $stub->expects($this->any()) + ->method('delete') ->will($this->returnValue('response')); foreach (array('get', 'post', 'put', 'delete') as $method) { diff --git a/tests/Upwork/API/ConfigTest.php b/tests/Upwork/API/ConfigTest.php index 9d54b7b..9449f30 100644 --- a/tests/Upwork/API/ConfigTest.php +++ b/tests/Upwork/API/ConfigTest.php @@ -3,16 +3,18 @@ require __DIR__ . '/../../../vendor/autoload.php'; +use PHPUnit\Framework\TestCase; use Upwork\API\Config as Config; use Upwork\API\ApiException as ApiException; -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends TestCase { /** * @expectedException Upwork\API\ApiException */ public function testBadProperty() { + $this->expectException(\Upwork\API\ApiException::class); throw new ApiException('test'); } @@ -27,7 +29,7 @@ public function testDefaultProperty() $helper = new Config(array()); $property->setValue($helper, true); $helper->__construct(array()); // will not change the attribute value - $this->assertAttributeEquals(true, '_verifySsl', $helper); + $this->assertTrue($helper::get('verifySsl')); } /** @@ -35,13 +37,13 @@ public function testDefaultProperty() */ public function testSetProperty() { - $reflection = new \ReflectionClass('Upwork\API\Config'); + $reflection = new \ReflectionClass(Config::class); $property = $reflection->getProperty('_verifySsl'); $property->setAccessible(true); $helper = new Config(array()); $property->setValue($helper, false); $helper->__construct(array('verifySsl' => true)); - $this->assertAttributeEquals(true, '_verifySsl', $helper); + $this->assertTrue($helper::get('verifySsl')); } /** diff --git a/tests/Upwork/API/DebugTest.php b/tests/Upwork/API/DebugTest.php index aa10948..983c3bb 100644 --- a/tests/Upwork/API/DebugTest.php +++ b/tests/Upwork/API/DebugTest.php @@ -3,9 +3,10 @@ require __DIR__ . '/../../../vendor/autoload.php'; +use PHPUnit\Framework\TestCase; use Upwork\API\Debug as ApiDebug; -class DebugTest extends \PHPUnit_Framework_TestCase +class DebugTest extends TestCase { /** * @test @@ -17,14 +18,13 @@ public function testPrintDebugMessage() $property->setAccessible(true); $helper = new ApiDebug(); $property->setValue($helper, true); - $this->assertAttributeEquals(true, '_debug', $helper); ob_start(); ApiDebug::p('test message'); $output = ob_get_contents(); ob_end_clean(); - $this->assertContains('test message', $output); + $this->assertStringContainsString('test message', $output); $property->setValue($helper, false); } } diff --git a/tests/Upwork/API/Interfaces/ClientTest.php b/tests/Upwork/API/Interfaces/ClientTest.php index b9435b8..4c0d7c4 100644 --- a/tests/Upwork/API/Interfaces/ClientTest.php +++ b/tests/Upwork/API/Interfaces/ClientTest.php @@ -3,7 +3,9 @@ require __DIR__ . '/../../../../vendor/autoload.php'; -class InterfaceClientTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class ClientTest extends TestCase { /** * @test diff --git a/tests/Upwork/API/Routers/Activities/EngagementTest.php b/tests/Upwork/API/Routers/Activities/EngagementTest.php index c7fa8fd..434fc40 100644 --- a/tests/Upwork/API/Routers/Activities/EngagementTest.php +++ b/tests/Upwork/API/Routers/Activities/EngagementTest.php @@ -10,7 +10,7 @@ class EngagementTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Activities/TeamTest.php b/tests/Upwork/API/Routers/Activities/TeamTest.php index 52f5a74..2e147a6 100644 --- a/tests/Upwork/API/Routers/Activities/TeamTest.php +++ b/tests/Upwork/API/Routers/Activities/TeamTest.php @@ -10,7 +10,7 @@ class TeamTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/AuthTest.php b/tests/Upwork/API/Routers/AuthTest.php index a07e60a..0d8f935 100644 --- a/tests/Upwork/API/Routers/AuthTest.php +++ b/tests/Upwork/API/Routers/AuthTest.php @@ -8,7 +8,7 @@ class AuthTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/CommonTestRouter.php b/tests/Upwork/API/Routers/CommonTestRouter.php index f3e459a..6f5c24c 100644 --- a/tests/Upwork/API/Routers/CommonTestRouter.php +++ b/tests/Upwork/API/Routers/CommonTestRouter.php @@ -3,10 +3,11 @@ require __DIR__ . '/../../../../vendor/autoload.php'; +use PHPUnit\Framework\TestCase; use Upwork\API\Debug as ApiDebug; use Upwork\API\Config as ApiConfig; -class CommonTestRouter extends \PHPUnit_Framework_TestCase +class CommonTestRouter extends TestCase { /** @var Client mock */ protected $_client; @@ -14,7 +15,7 @@ class CommonTestRouter extends \PHPUnit_Framework_TestCase /** * Setup */ - public function setUp() + protected function setUp(): void { $config = new ApiConfig( array( @@ -25,13 +26,25 @@ public function setUp() $result = new \StdClass; $result->server_time = '1111111111'; - $result->auth_user = array(); + $result->auth_user = []; $result->body = 1; - $stub = $this->getMock('Upwork\API\Client', array('_request'), array($config)); + $stub = $this->getMockBuilder(\Upwork\API\Client::class) + ->enableArgumentCloning() + ->setConstructorArgs([$config]) + ->getMock(); $stub->expects($this->any()) - ->method('_request') - ->will($this->returnValue($result)); + ->method('get') + ->will($this->returnValue($result)); + $stub->expects($this->any()) + ->method('post') + ->will($this->returnValue($result)); + $stub->expects($this->any()) + ->method('put') + ->will($this->returnValue($result)); + $stub->expects($this->any()) + ->method('delete') + ->will($this->returnValue($result)); $this->_client = $stub; } @@ -47,9 +60,9 @@ protected function _checkResponse($response) $this->assertObjectHasAttribute('server_time', $response); $this->assertObjectHasAttribute('auth_user', $response); $this->assertObjectHasAttribute('body', $response); - $this->assertInternalType('string', $response->server_time); - $this->assertInternalType('array', $response->auth_user); - $this->assertInternalType('integer', $response->body); + $this->assertIsString($response->server_time); + $this->assertIsArray($response->auth_user); + $this->assertIsInt($response->body); $this->assertSame('1111111111', $response->server_time); $this->assertSame(1, $response->body); } diff --git a/tests/Upwork/API/Routers/Freelancers/ProfileTest.php b/tests/Upwork/API/Routers/Freelancers/ProfileTest.php index 2b4ffd3..e726e32 100644 --- a/tests/Upwork/API/Routers/Freelancers/ProfileTest.php +++ b/tests/Upwork/API/Routers/Freelancers/ProfileTest.php @@ -5,12 +5,12 @@ require_once __DIR__ . '/../CommonTestRouter.php'; -class FreelancersTest extends CommonTestRouter +class ProfileTest extends CommonTestRouter { /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Freelancers/SearchTest.php b/tests/Upwork/API/Routers/Freelancers/SearchTest.php index ca2b86d..2775a49 100644 --- a/tests/Upwork/API/Routers/Freelancers/SearchTest.php +++ b/tests/Upwork/API/Routers/Freelancers/SearchTest.php @@ -10,7 +10,7 @@ class SearchTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Hr/Clients/ApplicationsTest.php b/tests/Upwork/API/Routers/Hr/Clients/ApplicationsTest.php index 8c9e354..a3b2d3c 100644 --- a/tests/Upwork/API/Routers/Hr/Clients/ApplicationsTest.php +++ b/tests/Upwork/API/Routers/Hr/Clients/ApplicationsTest.php @@ -10,7 +10,7 @@ class ApplicationsTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Hr/Clients/OffersTest.php b/tests/Upwork/API/Routers/Hr/Clients/OffersTest.php index 22db965..db769a6 100644 --- a/tests/Upwork/API/Routers/Hr/Clients/OffersTest.php +++ b/tests/Upwork/API/Routers/Hr/Clients/OffersTest.php @@ -10,7 +10,7 @@ class OffersTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Hr/ContractsTest.php b/tests/Upwork/API/Routers/Hr/ContractsTest.php index 532d96f..7c06b00 100644 --- a/tests/Upwork/API/Routers/Hr/ContractsTest.php +++ b/tests/Upwork/API/Routers/Hr/ContractsTest.php @@ -10,7 +10,7 @@ class ContractsTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Hr/EngagamentsTest.php b/tests/Upwork/API/Routers/Hr/EngagementsTest.php similarity index 95% rename from tests/Upwork/API/Routers/Hr/EngagamentsTest.php rename to tests/Upwork/API/Routers/Hr/EngagementsTest.php index 066f439..a7e927a 100644 --- a/tests/Upwork/API/Routers/Hr/EngagamentsTest.php +++ b/tests/Upwork/API/Routers/Hr/EngagementsTest.php @@ -10,7 +10,7 @@ class EngagementsTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Hr/Freelancers/ApplicationsTest.php b/tests/Upwork/API/Routers/Hr/Freelancers/ApplicationsTest.php index 45ffdaa..39b6ed4 100644 --- a/tests/Upwork/API/Routers/Hr/Freelancers/ApplicationsTest.php +++ b/tests/Upwork/API/Routers/Hr/Freelancers/ApplicationsTest.php @@ -10,7 +10,7 @@ class ApplicationsTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Hr/Freelancers/OffersTest.php b/tests/Upwork/API/Routers/Hr/Freelancers/OffersTest.php index 286ac88..026fe8e 100644 --- a/tests/Upwork/API/Routers/Hr/Freelancers/OffersTest.php +++ b/tests/Upwork/API/Routers/Hr/Freelancers/OffersTest.php @@ -10,7 +10,7 @@ class OffersTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Hr/InterviewsTest.php b/tests/Upwork/API/Routers/Hr/InterviewsTest.php index b7ba452..cf654bf 100644 --- a/tests/Upwork/API/Routers/Hr/InterviewsTest.php +++ b/tests/Upwork/API/Routers/Hr/InterviewsTest.php @@ -10,7 +10,7 @@ class InterviewsTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Hr/JobsTest.php b/tests/Upwork/API/Routers/Hr/JobsTest.php index 474f1ed..a2fd5df 100644 --- a/tests/Upwork/API/Routers/Hr/JobsTest.php +++ b/tests/Upwork/API/Routers/Hr/JobsTest.php @@ -10,7 +10,7 @@ class JobsTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Hr/MilestonesTest.php b/tests/Upwork/API/Routers/Hr/MilestonesTest.php index 12cd487..b80552a 100644 --- a/tests/Upwork/API/Routers/Hr/MilestonesTest.php +++ b/tests/Upwork/API/Routers/Hr/MilestonesTest.php @@ -10,7 +10,7 @@ class MilestonesTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -87,7 +87,7 @@ public function testApprove() public function testDelete() { $router = new \Upwork\API\Routers\Hr\Milestones($this->_client); - $response = $router->delete('1234'); + $response = $router->deleteMilestone('1234'); $this->_checkResponse($response); } diff --git a/tests/Upwork/API/Routers/Hr/RolesTest.php b/tests/Upwork/API/Routers/Hr/RolesTest.php index 74925b5..40c25da 100644 --- a/tests/Upwork/API/Routers/Hr/RolesTest.php +++ b/tests/Upwork/API/Routers/Hr/RolesTest.php @@ -10,7 +10,7 @@ class RolesTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Hr/SubmissionsTest.php b/tests/Upwork/API/Routers/Hr/SubmissionsTest.php index d455e9d..d494ad1 100644 --- a/tests/Upwork/API/Routers/Hr/SubmissionsTest.php +++ b/tests/Upwork/API/Routers/Hr/SubmissionsTest.php @@ -10,7 +10,7 @@ class SubmissionsTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Jobs/ProfileTest.php b/tests/Upwork/API/Routers/Jobs/ProfileTest.php index 70fb209..02a414f 100644 --- a/tests/Upwork/API/Routers/Jobs/ProfileTest.php +++ b/tests/Upwork/API/Routers/Jobs/ProfileTest.php @@ -5,12 +5,12 @@ require_once __DIR__ . '/../CommonTestRouter.php'; -class JobsTest extends CommonTestRouter +class ProfileTest extends CommonTestRouter { /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Jobs/SearchTest.php b/tests/Upwork/API/Routers/Jobs/SearchTest.php index cf69462..9f28b05 100644 --- a/tests/Upwork/API/Routers/Jobs/SearchTest.php +++ b/tests/Upwork/API/Routers/Jobs/SearchTest.php @@ -10,7 +10,7 @@ class SearchTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/MessagesTest.php b/tests/Upwork/API/Routers/MessagesTest.php index c9472ee..dd7071f 100644 --- a/tests/Upwork/API/Routers/MessagesTest.php +++ b/tests/Upwork/API/Routers/MessagesTest.php @@ -8,7 +8,7 @@ class MessagesTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -19,7 +19,7 @@ public function setUp() public function testGetRooms() { $router = new \Upwork\API\Routers\Messages($this->_client); - $response = $router->getRooms(); + $response = $router->getRooms('company'); $this->_checkResponse($response); } @@ -90,6 +90,17 @@ public function testSendMesageToRoom() $this->_checkResponse($response); } + /** + * @test + */ + public function testSendMesageToRooms() + { + $router = new \Upwork\API\Routers\Messages($this->_client); + $response = $router->sendMessageToRooms('company', array()); + + $this->_checkResponse($response); + } + /** * @test */ diff --git a/tests/Upwork/API/Routers/MetadataTest.php b/tests/Upwork/API/Routers/MetadataTest.php index 9c4c5d0..bbe2248 100644 --- a/tests/Upwork/API/Routers/MetadataTest.php +++ b/tests/Upwork/API/Routers/MetadataTest.php @@ -8,7 +8,7 @@ class MetadataTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Organization/CompaniesTest.php b/tests/Upwork/API/Routers/Organization/CompaniesTest.php index c5997d3..3670131 100644 --- a/tests/Upwork/API/Routers/Organization/CompaniesTest.php +++ b/tests/Upwork/API/Routers/Organization/CompaniesTest.php @@ -10,7 +10,7 @@ class CompaniesTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Organization/TeamsTest.php b/tests/Upwork/API/Routers/Organization/TeamsTest.php index 6ba383f..1f5d9b2 100644 --- a/tests/Upwork/API/Routers/Organization/TeamsTest.php +++ b/tests/Upwork/API/Routers/Organization/TeamsTest.php @@ -10,7 +10,7 @@ class TeamsTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Organization/UsersTest.php b/tests/Upwork/API/Routers/Organization/UsersTest.php index 1d4c539..8a8e66c 100644 --- a/tests/Upwork/API/Routers/Organization/UsersTest.php +++ b/tests/Upwork/API/Routers/Organization/UsersTest.php @@ -10,7 +10,7 @@ class UsersTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/PaymentsTest.php b/tests/Upwork/API/Routers/PaymentsTest.php index 9ff32ea..afee914 100644 --- a/tests/Upwork/API/Routers/PaymentsTest.php +++ b/tests/Upwork/API/Routers/PaymentsTest.php @@ -8,7 +8,7 @@ class PaymentsTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Reports/Finance/AccountsTest.php b/tests/Upwork/API/Routers/Reports/Finance/AccountsTest.php index 24c8a2f..e8ddf5e 100644 --- a/tests/Upwork/API/Routers/Reports/Finance/AccountsTest.php +++ b/tests/Upwork/API/Routers/Reports/Finance/AccountsTest.php @@ -10,7 +10,7 @@ class AccountsTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Reports/Finance/BillingsTest.php b/tests/Upwork/API/Routers/Reports/Finance/BillingsTest.php index 9aa0808..e3a6636 100644 --- a/tests/Upwork/API/Routers/Reports/Finance/BillingsTest.php +++ b/tests/Upwork/API/Routers/Reports/Finance/BillingsTest.php @@ -10,7 +10,7 @@ class BillingsTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Reports/Finance/EarningsTest.php b/tests/Upwork/API/Routers/Reports/Finance/EarningsTest.php index 2488700..c118d03 100644 --- a/tests/Upwork/API/Routers/Reports/Finance/EarningsTest.php +++ b/tests/Upwork/API/Routers/Reports/Finance/EarningsTest.php @@ -10,7 +10,7 @@ class EarningsTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/Reports/TimeTest.php b/tests/Upwork/API/Routers/Reports/TimeTest.php index 03efafb..4d9757c 100644 --- a/tests/Upwork/API/Routers/Reports/TimeTest.php +++ b/tests/Upwork/API/Routers/Reports/TimeTest.php @@ -10,7 +10,7 @@ class TimeTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/SnapshotTest.php b/tests/Upwork/API/Routers/SnapshotTest.php index 6bf3713..a8a27da 100644 --- a/tests/Upwork/API/Routers/SnapshotTest.php +++ b/tests/Upwork/API/Routers/SnapshotTest.php @@ -8,7 +8,7 @@ class SnapshotTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/WorkdaysTest.php b/tests/Upwork/API/Routers/WorkdaysTest.php index d5ecba8..f85d492 100644 --- a/tests/Upwork/API/Routers/WorkdaysTest.php +++ b/tests/Upwork/API/Routers/WorkdaysTest.php @@ -8,7 +8,7 @@ class WorkdaysTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } diff --git a/tests/Upwork/API/Routers/WorkdiaryTest.php b/tests/Upwork/API/Routers/WorkdiaryTest.php index 159d3c0..6e5ad7b 100644 --- a/tests/Upwork/API/Routers/WorkdiaryTest.php +++ b/tests/Upwork/API/Routers/WorkdiaryTest.php @@ -8,7 +8,7 @@ class WorkdiaryTest extends CommonTestRouter /** * Setup */ - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -16,10 +16,10 @@ public function setUp() /** * @test */ - public function testGet() + public function testGetByCompany() { $router = new \Upwork\API\Routers\Workdiary($this->_client); - $response = $router->get('company', '20140101', array()); + $response = $router->getByCompany('company', '20140101', array()); $this->_checkResponse($response); } @@ -30,7 +30,7 @@ public function testGet() public function testGetByContract() { $router = new \Upwork\API\Routers\Workdiary($this->_client); - $response = $router->getByContract('1234', array()); + $response = $router->getByContract('1234', '20140101', array()); $this->_checkResponse($response); } diff --git a/tests/Upwork/API/UtilsTest.php b/tests/Upwork/API/UtilsTest.php index 9c44d09..f90d5cc 100644 --- a/tests/Upwork/API/UtilsTest.php +++ b/tests/Upwork/API/UtilsTest.php @@ -1,11 +1,12 @@ Date: Fri, 18 Sep 2020 15:58:24 +0200 Subject: [PATCH 3/3] Changes for v1.4.0 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6af3453..7607b27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: - "5.6" fast_finish: true -script: ./vendor/phpunit/phpunit/phpunit.php --stderr +script: ./vendor/phpunit/phpunit/phpunit --stderr notifications: email: