diff --git a/.travis.yml b/.travis.yml index b24c35d..703cb27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ cache: - $HOME/.composer/cache php: - - '5.3' - '5.4' - '5.5' - '5.6' diff --git a/composer.json b/composer.json index a12d81c..90f4b93 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ ], "require": { "php": ">=5.3.0", - "ext-curl": "*" + "ext-curl": "*", + "phpunit/phpunit": "4.8.29" }, "support": { "email": "support@retailcrm.pro" diff --git a/lib/RetailCrm/ApiClient.php b/lib/RetailCrm/ApiClient.php index 7fb1810..22fd304 100644 --- a/lib/RetailCrm/ApiClient.php +++ b/lib/RetailCrm/ApiClient.php @@ -1754,6 +1754,32 @@ class ApiClient ); } + /** + * Edit marketplace configuration + * + * @param array $configuration + * + * @throws \RetailCrm\Exception\InvalidJsonException + * @throws \RetailCrm\Exception\CurlException + * @throws \InvalidArgumentException + * + * @return ApiResponse + */ + public function marketplaceSettingsEdit(array $configuration) + { + if (!count($configuration) || empty($configuration['code'])) { + throw new \InvalidArgumentException( + 'Parameter `configuration` must contains a data & configuration `code` must be set' + ); + } + + return $this->client->makeRequest( + sprintf('/marketplace/external/setting/%s/edit', $configuration['code']), + Client::METHOD_POST, + array('configuration' => json_encode($configuration)) + ); + } + /** * Update CRM basic statistic * diff --git a/tests/RetailCrm/Test/TestCase.php b/tests/RetailCrm/Test/TestCase.php index 57d3067..bd23a0f 100644 --- a/tests/RetailCrm/Test/TestCase.php +++ b/tests/RetailCrm/Test/TestCase.php @@ -23,7 +23,7 @@ class TestCase extends \PHPUnit_Framework_TestCase $site ?: (isset($_SERVER['CRM_SITE']) ? $_SERVER['CRM_SITE'] : null) ); } - + /** * Return Client object * diff --git a/tests/RetailCrm/Tests/ApiClientMarketplaceTest.php b/tests/RetailCrm/Tests/ApiClientMarketplaceTest.php new file mode 100644 index 0000000..cb66246 --- /dev/null +++ b/tests/RetailCrm/Tests/ApiClientMarketplaceTest.php @@ -0,0 +1,44 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + */ + +namespace RetailCrm\Tests; + +use RetailCrm\Test\TestCase; + + +class ApiClientMarketplaceTest extends TestCase +{ + const SNAME = 'Marketplace integration'; + const SCODE = 'integration'; + + /** + * @group marketplace + */ + public function testConfigurationEdit() + { + $client = static::getApiClient(); + + $response = $client->marketplaceSettingsEdit( + array( + 'name' => self::SNAME, + 'code' => self::SCODE, + 'logo' => 'http://download.retailcrm.pro/logos/setup.svg', + 'active' => 'true' + ) + ); + + $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + $this->assertTrue(in_array($response->getStatusCode(), array(200, 201))); + $this->assertTrue($response->isSuccessful()); + } +} diff --git a/tests/RetailCrm/Tests/ApiClientReferenceTest.php b/tests/RetailCrm/Tests/ApiClientReferenceTest.php index 3ccf2d2..3ee6076 100644 --- a/tests/RetailCrm/Tests/ApiClientReferenceTest.php +++ b/tests/RetailCrm/Tests/ApiClientReferenceTest.php @@ -77,16 +77,14 @@ class ApiClientReferenceTest extends TestCase } $response = $client->$method($params); - $this->assertEquals(201, $response->getStatusCode()); + $this->assertTrue(in_array($response->getStatusCode(), array(200, 201))); $response = $client->$method(array( 'code' => $code, 'name' => 'Bbb', )); - if ($response->getStatusCode() > 201) { - print_r($response); - } - $this->assertEquals(200, $response->getStatusCode()); + + $this->assertTrue(in_array($response->getStatusCode(), array(200, 201))); } /** diff --git a/tests/RetailCrm/Tests/ApiClientStoreTest.php b/tests/RetailCrm/Tests/ApiClientStoreTest.php index cf31b7a..9a0b0d0 100644 --- a/tests/RetailCrm/Tests/ApiClientStoreTest.php +++ b/tests/RetailCrm/Tests/ApiClientStoreTest.php @@ -104,7 +104,7 @@ class ApiClientStoreTest extends TestCase )); $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertTrue($response->isSuccessful()); + $this->assertFalse($response->isSuccessful()); } /**