1
0
mirror of synced 2025-02-16 15:03:17 +03:00

Merge pull request #19 from gwinn/v3

V3
This commit is contained in:
Alex Lushpai 2016-07-22 02:36:51 +04:00 committed by GitHub
commit e6ba6d1155
4 changed files with 86 additions and 24 deletions

17
.travis.yml Normal file
View File

@ -0,0 +1,17 @@
language: php
cache:
directories:
- $HOME/.composer/cache
php:
- '5.3'
- '5.4'
- '5.5'
- '5.6'
before_script:
- flags="--prefer-dist --no-dev"
- composer install $flags
script: phpunit

View File

@ -15,16 +15,6 @@
"php": ">=5.3.0", "php": ">=5.3.0",
"ext-curl": "*" "ext-curl": "*"
}, },
"require-dev": {
"phpunit/phpunit": "5.2.*",
"phpunit/php-code-coverage": "3.3.0",
"phpunit/php-invoker": "1.1.4",
"phpmd/phpmd": "2.4.*",
"sebastian/phpcpd": "2.0.*",
"sebastian/phpdcd": "1.0.*",
"squizlabs/php_codesniffer": "2.5.*",
"apigen/apigen": "4.1.*"
},
"support": { "support": {
"email": "support@retailcrm.pro" "email": "support@retailcrm.pro"
}, },

View File

@ -6,16 +6,16 @@
colors="true" colors="true"
verbose="true" verbose="true"
processIsolation="false" processIsolation="false"
stopOnFailure="true"> stopOnFailure="false">
<!-- Dummy values used to provide credentials. No need to change these. --> <!-- Dummy values used to provide credentials. No need to change these. -->
<php> <php>
<server name="CRM_URL" value="foo" /> <server name="CRM_URL" value="https://demo.retailcrm.ru" />
<server name="CRM_API_KEY" value="bar" /> <server name="CRM_API_KEY" value="nSBFWecViONG5c96wUQQgZzHkilTnaa6" />
<server name="CRM_SITE" value="zoo" /> <server name="CRM_SITE" value="b12-skillum-ru" />
<server name="CRM_STORE" value="moo" /> <server name="CRM_STORE" value="online" />
<server name="CRM_PACK_ITEM" value="boo" /> <server name="CRM_PACK_ITEM" value="88892" />
<server name="CRM_PACK_QUANTITY" value="goo" /> <server name="CRM_PACK_QUANTITY" value="2" />
</php> </php>
<testsuites> <testsuites>

View File

@ -1,13 +1,52 @@
<?php <?php
/**
* PHP version 5.3
*
* API client packs test class
*
* @category RetailCrm
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
*/
namespace RetailCrm\Tests; namespace RetailCrm\Tests;
use RetailCrm\Test\TestCase; use RetailCrm\Test\TestCase;
/**
* Class ApiClientPacksTest
*
* @category RetailCrm
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
*/
class ApiClientPacksTest extends TestCase class ApiClientPacksTest extends TestCase
{ {
private $_packId;
/** /**
* ApiClientPacksTest constructor.
*
* @param null|string $name name
* @param array $data data
* @param string $dataName dataName
*/
public function __construct($name = null, array $data = array(), $dataName = '')
{
parent::__construct($name, $data, $dataName);
$this->_packId = __DIR__ . '/../../../pack.tmp';
}
/**
* Test packs history
*
* @group integration * @group integration
* @return void
*/ */
public function testOrdersPacksHistory() public function testOrdersPacksHistory()
{ {
@ -28,7 +67,10 @@ class ApiClientPacksTest extends TestCase
} }
/** /**
* Test packs create
*
* @group integration * @group integration
* @return void
*/ */
public function testOrdersPacksCreate() public function testOrdersPacksCreate()
{ {
@ -40,13 +82,17 @@ class ApiClientPacksTest extends TestCase
); );
$response = $client->ordersPacksCreate($pack); $response = $client->ordersPacksCreate($pack);
file_put_contents($this->_packId, $response["id"]);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(201, $response->getStatusCode()); $this->assertEquals(201, $response->getStatusCode());
$this->assertTrue($response->success); $this->assertTrue($response->success);
} }
/** /**
* Test packs failed create
*
* @group integration * @group integration
* @return void
*/ */
public function testOrdersPacksCreateFailed() public function testOrdersPacksCreateFailed()
{ {
@ -64,28 +110,37 @@ class ApiClientPacksTest extends TestCase
} }
/** /**
* Test packs get
*
* @group integration * @group integration
* @return void
*/ */
public function testOrdersPacksGet() public function testOrdersPacksGet()
{ {
$client = static::getApiClient(); $client = static::getApiClient();
$response = $client->ordersPacksGet(1); $packId = file_get_contents($this->_packId);
$response = $client->ordersPacksGet($packId);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success); $this->assertTrue($response->success);
} }
/** /**
* Test packs delete
*
* @group integration * @group integration
* @return void
*/ */
public function testOrdersPacksDelete() public function testOrdersPacksDelete()
{ {
$client = static::getApiClient(); $client = static::getApiClient();
$response = $client->ordersPacksDelete(1); $packId = file_get_contents($this->_packId);
$response = $client->ordersPacksDelete($packId);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success); $this->assertTrue($response->success);
unlink($this->_packId);
} }
} }