diff --git a/.gitignore b/.gitignore index 0aedfcf..13501e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ index.php -tools -logs config.json -.idea \ No newline at end of file +.idea +composer.lock +vendor \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b9f745..84152d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 0.4.0 +- Complete ReDesign. + # 0.2.0 (15.08.2016) ## Enhancements @@ -11,7 +14,7 @@ ## Bugfixes - #122 Move InformationTrait file. -- #143 Delete InputValidator::isRESTCommand function. +- #143 Delete ::isRESTCommand function. - #156 Fix using other shop locale. ## Features diff --git a/README.md b/README.md index 713b67b..06334ad 100644 --- a/README.md +++ b/README.md @@ -2,61 +2,44 @@ This is the PHP REST SDK to easily connect to an ePages shop. You can use it as a developer to develop apps for ePages. -Just sign up for the [ePages Developer Program](http://www.epages.cloud/developer/) and create a free developer test shop. +Just sign up for the [ePages Developer Program](https://developer.epages.com/) and create a free developer test shop. ## Requirements To use this SDK, you'll need: -* at least **PHP 5.5** +* at least **PHP 7.0** All dependencies comes automatically with the client and could be updated via composer. -## Installation +## Installation via composer -### Via composer -Its recommended to get the client via **Composer**. +Its easy to get the client via **Composer**. Just search for [epages/rest-sdk](https://packagist.org/packages/epages/rest-sdk) and put this to you composer.yml file: ```php { "require": { - "php": ">=5.4.0", "epages/rest-sdk": ">=0.2" } } ``` -### Direct download -To use the client directly without getting composer just download the **.phar** archive and include it. - -``` -wget https://raw.githubusercontent.com/ePages-de/epages-rest-php/master/build/epages-rest-php.phar -O epages-rest-php.phar -``` - -It is also possible to download the PHP file archive manually. -Check for the latest **.phar** release in the [releases area](https://github.com/ePages-de/epages-rest-php/releases). - -To use the SDK, you simply have to include it. -**Warning:** It is not recommended to do this in live system! -```php -require_once("libraries/epages-rest-php.phar"); -``` - ## Configuration You can configure it with putting a **config.json** into you main directory. Just copy the **config.example.json** from GitHub or create a new one: ```javascript { - "logging": - { - "level": "NONE", - "output": "SCREEN", - "outputfile": null + "Client": { + "host": "www.some.host", + "shop": "shopName", + "isSSL": true, + "userAgent": "UserAgent", + "token": "TheTokenIfExists" }, - "formatting": - { - "format": "HTML" + "Logger": { + "level": "ERROR", + "output": "SCREEN" } } ``` @@ -115,24 +98,24 @@ $products = $productFilter->getProducts(); // print the products foreach ($products as $product) { - echo "

" . htmlentities($product->getName()) . "

"; - echo "

"; - echo "getSmallImage()->getOriginURL() . "\"/>"; - echo "ProductID: " . $product->getID() . "
"; - echo "Description: " . htmlentities($product->getDescription()) . "

"; - echo "This product is "; - if (!$product->isForSale()) { - echo "NOT "; - } - echo "for sale and is "; - if ($product->isSpecialOffer()) { - echo "a "; - } - else { - echo "not a "; - } - echo "special offer."; - echo "


"; + echo "

" . htmlentities($product->getName()) . "

"; + echo "

"; + echo "getSmallImage()->getOriginURL() . "\"/>"; + echo "ProductID: " . $product->getID() . "
"; + echo "Description: " . htmlentities($product->getDescription()) . "

"; + echo "This product is "; + if (!$product->isForSale()) { + echo "NOT "; + } + echo "for sale and is "; + if ($product->isSpecialOffer()) { + echo "a "; + } + else { + echo "not a "; + } + echo "special offer."; + echo "


"; } ``` diff --git a/circle.yml b/circle.yml deleted file mode 100644 index e0f1784..0000000 --- a/circle.yml +++ /dev/null @@ -1,3 +0,0 @@ -machine: - php: - version: 5.4.4 \ No newline at end of file diff --git a/composer.json b/composer.json index 3b37d86..383ea0a 100644 --- a/composer.json +++ b/composer.json @@ -7,5 +7,11 @@ "license": "MIT", "require": { "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "6.4.4" + }, + "autoload": { + "classmap": ["src/"] } } \ No newline at end of file diff --git a/config.example.json b/config.example.json index a86f753..0ada7f5 100644 --- a/config.example.json +++ b/config.example.json @@ -1,33 +1,13 @@ { - "logging": - { - "level": "NOTIFICATION", - "output": "SCREEN", - "outputfile": null + "Client": { + "host": "www.some.host", + "shop": "shopName", + "isSSL": true, + "userAgent": "UserAgent", + "token": "TheTokenIfExists" }, - "formatting": - { - "image": - { - "formatters": ["IMAGE", "NEWLINE"], - "classes": ["testClass1", "testClass2"], - "id": "testID", - "attributes": - { - "testAttribute1": "testValue1", - "testAttribute2": "testValue2" - } - }, - "bold": - { - "formatters": ["BOLD", "NEWLINE"], - "classes": ["testClass1", "testClass2"], - "id": "testID", - "attributes": - { - "testAttribute1": "testValue1", - "testAttribute2": "testValue2" - } - } + "Logger": { + "level": "ERROR", + "output": "SCREEN" } } \ No newline at end of file diff --git a/examples/connectingSettings.php b/examples/connectingSettings.php index bf3fc78..56cdc2e 100644 --- a/examples/connectingSettings.php +++ b/examples/connectingSettings.php @@ -17,7 +17,7 @@ * * This can throw a JSONDecodingException. If everything works correct this function will return the value true. */ -Configuration::addConfigurationFromFile('/path/to/a/JSON/file'); +Configuration::addFromFile('/path/to/a/JSON/file'); /** * Solution 2.1: Define it via array. @@ -25,7 +25,7 @@ * To connect to more different shops in one script call (e.g. having Crons) there is also the possibility to load * Configuration via array. */ -Configuration::setConfiguration([ +Configuration::set([ 'Client' => [ 'host' => 'www.example.com', 'shop' => 'MyCoolShop', @@ -40,7 +40,7 @@ * * There is also the possibility to only right a specific module with adding the Configuration with array. */ -Configuration::setConfiguration( +Configuration::set( [ 'host' => 'www.example.com', 'shop' => 'MyCoolShop', @@ -55,7 +55,7 @@ * If you want to change some Client configuration, like host, but not change the other Client Configurations you can * extend the Configuration. */ -Configuration::extendConfiguration( +Configuration::extend( [ 'host' => 'www.example.org' ], @@ -67,5 +67,5 @@ * * To delete the static Configuration settings just use the reset function. */ -Configuration::resetConfiguration(); // Reset complete Configuration -Configuration::resetConfiguration('Client'); // Only reset the Client configuration +Configuration::reset(); // Reset complete Configuration +Configuration::reset('Client'); // Only reset the Client configuration diff --git a/examples/logMessages.php b/examples/logMessages.php index 149b7b3..0425dfc 100644 --- a/examples/logMessages.php +++ b/examples/logMessages.php @@ -16,8 +16,8 @@ * * The Logger can be configured via JSON file or array. */ -Configuration::addConfigurationFromFile('dir/and/filename.json'); // configure via JSON -Configuration::setConfiguration( +Configuration::addFromFile('dir/and/filename.json'); // configure via JSON +Configuration::set( [ 'Logger' => [ 'level' => LogLevel::ERROR, diff --git a/phpunit.xml b/phpunit.xml index d9746c6..0a28eb5 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,49 +1,7 @@ - - - - tests/util/RESTClientTest.php - - - tests/ShopTest.php - - - tests/util/InputValidatorTest.php - - - tests/shopobjects/information/ContactInformationTest.php - - - tests/shopobjects/information/PrivacyPolicyInformationTest.php - - - tests/shopobjects/information/RightOfWithdrawalInformationTest.php - - - tests/shopobjects/information/ShippingInformationTest.php - - - tests/shopobjects/information/TermsAndConditionInformationTest.php - - - tests/shopobjects/address/AddressTest.php - - - tests/shopobjects/date/DateTest.php - - - tests/shopobjects/method/PaymentMethodTest.php - - - tests/shopobjects/method/ShippingMethodTest.php - - - tests/shopobjects/order/OrderTest.php - - - - - utility - shopobjects - - + + + + tests/EpSDKTest/Configuration/ConfigurationTest.php + + diff --git a/src/EpSDK/Configuration/Configuration.php b/src/EpSDK/Configuration/Configuration.php index f06c67a..ececc10 100644 --- a/src/EpSDK/Configuration/Configuration.php +++ b/src/EpSDK/Configuration/Configuration.php @@ -1,4 +1,6 @@ $configuration) { - self::extendConfiguration($configuration, $module); + self::extend($configuration, $module); } return true; } @@ -50,12 +52,12 @@ public static function addConfigurationFromFile(string $pathToFile): bool * @return bool * @since 0.4.0 */ - public static function extendConfiguration(array $configuration, string $module): bool + public static function extend(array $configuration, string $module): bool { if (isset(self::$configuration[$module])) { self::$configuration[$module] = \array_merge(self::$configuration[$module], $configuration); } else { - self::setConfiguration($configuration, $module); + self::set($configuration, $module); } return true; } @@ -67,12 +69,11 @@ public static function extendConfiguration(array $configuration, string $module) * @return array * @since 0.4.0 */ - public static function getConfiguration(string $module = null): array + public static function get(string $module = null): array { - if (null === $module) { - return self::$configuration; - } - return self::$configuration[$module] ?? []; + return null === $module + ? self::$configuration + : self::$configuration[$module] ?? []; } /** @@ -102,7 +103,7 @@ public static function saveToFile(string $fileName, string $module = null): bool * @return bool * @since 0.4.0 */ - public static function setConfiguration(array $configuration, string $module = null): bool + public static function set(array $configuration, string $module = null): bool { if (null === $module) { self::$configuration = $configuration; @@ -115,10 +116,11 @@ public static function setConfiguration(array $configuration, string $module = n /** * Reset the configuration. * + * @param string $module * @return bool * @since 0.4.0 */ - public static function resetConfiguration(string $module = null): bool + public static function reset(string $module = null): bool { if (null !== $module) { unset(self::$configuration[$module]); diff --git a/src/EpSDK/Connector/AbstractConnector.php b/src/EpSDK/Connector/AbstractConnector.php index 77d61ed..e480c60 100644 --- a/src/EpSDK/Connector/AbstractConnector.php +++ b/src/EpSDK/Connector/AbstractConnector.php @@ -1,5 +1,6 @@ $maximumNumberOfElements) { + } elseif ($numberOfItems > $maximumNumberOfElements) { $items = \array_slice($items, $maximumNumberOfElements); $retry = false; } else { diff --git a/src/EpSDK/Connector/ProductConnector.php b/src/EpSDK/Connector/ProductConnector.php index 761df00..d11170a 100644 --- a/src/EpSDK/Connector/ProductConnector.php +++ b/src/EpSDK/Connector/ProductConnector.php @@ -1,5 +1,6 @@ Image::class + 'images' => Image::class ]; /** @var array All attributes and their types. */ protected $attributeTypes = [ - 'shortDescription' => HTML::class, - 'description' => HTML::class, - 'priceInfo' => PriceInfo::class, - 'deliveryWeight' => Weight::class, - 'availabilityText' => HTML::class, - 'sfUrl' => URL::class + 'shortDescription' => HTML::class, + 'description' => HTML::class, + 'priceInfo' => PriceInfo::class, + 'deliveryWeight' => Weight::class, + 'availabilityText' => HTML::class, + 'sfUrl' => URL::class ]; /** @var string */ diff --git a/src/EpSDK/Constants.php b/src/EpSDK/Constants.php index 223e3e3..cf7246c 100644 --- a/src/EpSDK/Constants.php +++ b/src/EpSDK/Constants.php @@ -1,5 +1,6 @@ preConstruct(); } - // Initialize the Connector. - $this->connector = Configuration::getConfiguration('Connector')[\get_class($this)]; + // Initialize the Connector + if (empty(Configuration::get('Connector')[\get_class($this)])) { + include __DIR__ . '/loadConnectors.php'; + } + $this->connector = Configuration::get('Connector')[\get_class($this)]; foreach ($queryParameters as $parameter => $value) { $this->addQueryParameter($parameter, $value); diff --git a/src/EpSDK/ShopObject/Product.php b/src/EpSDK/ShopObject/Product.php index 9a86f21..7d75c07 100644 --- a/src/EpSDK/ShopObject/Product.php +++ b/src/EpSDK/ShopObject/Product.php @@ -1,5 +1,6 @@ null, - Constants::OBJECT_PARAMETER_CURERNCY => null + Constants::OBJECT_PARAMETER_CURRENCY => null ]; /** @var array Allowed request methods of this object. */ diff --git a/src/EpSDK/ShopObject/loadConnectors.php b/src/EpSDK/ShopObject/loadConnectors.php new file mode 100644 index 0000000..5df5154 --- /dev/null +++ b/src/EpSDK/ShopObject/loadConnectors.php @@ -0,0 +1,13 @@ + new ProductConnector() + ], + 'Connector' +); diff --git a/src/EpSDK/ShopObjectList/AbstractShopObjectList.php b/src/EpSDK/ShopObjectList/AbstractShopObjectList.php index a941663..6377f7e 100644 --- a/src/EpSDK/ShopObjectList/AbstractShopObjectList.php +++ b/src/EpSDK/ShopObjectList/AbstractShopObjectList.php @@ -1,5 +1,6 @@ connector = Configuration::getConfiguration('Connector')[$this->shopObjectName]; + $this->connector = Configuration::get('Connector')[$this->shopObjectName]; foreach ($queryParameters as $parameter => $value) { $this->addQueryParameter($parameter, $value); diff --git a/src/EpSDK/ShopObjectList/ProductList.php b/src/EpSDK/ShopObjectList/ProductList.php index 0ef07a7..da59886 100644 --- a/src/EpSDK/ShopObjectList/ProductList.php +++ b/src/EpSDK/ShopObjectList/ProductList.php @@ -18,16 +18,16 @@ class ProductList extends AbstractShopObjectList { /** @var array */ protected $queryParams = [ - 'locale' => null, - 'currency' => null, - 'page' => 1, - 'resultsPerPage' => 10, - 'direction' => null, - 'sort' => 'name', - 'q' => null, - 'categoryId' => null, - 'id' => null, - 'includeInvisible' => null + 'locale' => null, + 'currency' => null, + 'page' => 1, + 'resultsPerPage' => 10, + 'direction' => null, + 'sort' => 'name', + 'q' => null, + 'categoryId' => null, + 'id' => null, + 'includeInvisible' => null ]; /** @var array Allowed request methods of this object. */ diff --git a/src/EpSDK/Utility/Client/HTTPRequestMethod.php b/src/EpSDK/Utility/Client/HTTPRequestMethod.php index e643ba9..ee9017a 100644 --- a/src/EpSDK/Utility/Client/HTTPRequestMethod.php +++ b/src/EpSDK/Utility/Client/HTTPRequestMethod.php @@ -1,5 +1,6 @@ new ProductConnector() - ], - 'Connector' -); diff --git a/tests/EpSDKTest/Configuration/ConfigurationTest.php b/tests/EpSDKTest/Configuration/ConfigurationTest.php new file mode 100644 index 0000000..5aae246 --- /dev/null +++ b/tests/EpSDKTest/Configuration/ConfigurationTest.php @@ -0,0 +1,106 @@ + 'value'], 'SomeModule'); + + // WHEN + Configuration::extend(['var2' => 'value2'], 'SomeModule'); + + // THEN + self::assertEquals('value', Configuration::get('SomeModule')['var']); + self::assertEquals('value2', Configuration::get('SomeModule')['var2']); + self::assertEmpty(Configuration::get('NotExist')); + } + + public function testGetConfiguration() + { + // GIVEN / WHEN + Configuration::extend(['var' => 'value'], 'SomeModule'); + + // THEN + self::assertArrayHasKey('SomeModule', Configuration::get()); + self::assertArrayHasKey('var', Configuration::get('SomeModule')); + } + + public function testSetConfiguration() + { + // GIVEN + Configuration::set(['var' => 'value'], 'SomeModule'); + + // WHEN + Configuration::set(['var2' => 'value2'], 'SomeModule'); + + // THEN + self::assertArrayNotHasKey('var', Configuration::get('SomeModule')); + self::assertEquals('value2', Configuration::get('SomeModule')['var2']); + self::assertEmpty(Configuration::get('NotExist')); + } + + public function testResetModuleConfiguration() + { + // GIVEN + Configuration::set(['var' => 'value'], 'SomeModule'); + Configuration::set(['var' => 'value'], 'SomeModule2'); + + // WHEN + Configuration::reset('SomeModule'); + + // THEN + self::assertArrayNotHasKey('SomeModule', Configuration::get()); + self::assertArrayHasKey('SomeModule2', Configuration::get()); + } + + public function testResetConfiguration() + { + // GIVEN + Configuration::set(['var' => 'value'], 'SomeModule'); + Configuration::set(['var' => 'value'], 'SomeModule2'); + + // WHEN + Configuration::reset(); + + // THEN + self::assertArrayNotHasKey('SomeModule', Configuration::get()); + self::assertArrayNotHasKey('SomeModule2', Configuration::get()); + } +} diff --git a/tests/EpSDKTest/Configuration/emptyConfig.json b/tests/EpSDKTest/Configuration/emptyConfig.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/tests/EpSDKTest/Configuration/emptyConfig.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/tests/EpSDKTest/Configuration/testConfig.json b/tests/EpSDKTest/Configuration/testConfig.json new file mode 100644 index 0000000..a5a21b8 --- /dev/null +++ b/tests/EpSDKTest/Configuration/testConfig.json @@ -0,0 +1,5 @@ +{ + "SomeModule": { + "var" : "value" + } +} \ No newline at end of file diff --git a/tests/ShopTest.php b/tests/ShopTest.php deleted file mode 100644 index 778ecb0..0000000 --- a/tests/ShopTest.php +++ /dev/null @@ -1,108 +0,0 @@ -shop = new Shop("invalidDomain", "shopName"); - - // THEN - $this->assertTrue($this->shop->error()); - $this->assertEquals($this->shop->errorNumber(), "S-1"); - } - - /** - * @group shopobjects - */ - function testGetShopProperties() - { - // GIVEN / WHEN - $this->givenShop(); - - // THEN - $this->assertNotNull($this->shop->getBackofficeURL()); - $this->assertNotNull($this->shop->getLogo()); - $this->assertNotNull($this->shop->getName()); - $this->assertNotNull($this->shop->getStorefrontURL()); - } - - /** - * @group shopobjects - */ - function testShopLocales() - { - // GIVEN / WHEN - $this->givenShop(); - - // THEN - $this->assertEquals("en_GB", $this->shop->getDefaultLocale()); - $this->assertContains("de_DE", $this->shop->getLocales()); - } - - /** - * @group shopobjects - */ - function testShopCurrencies() - { - // GIVEN / WHEN - $this->givenShop(); - - // THEN - $this->assertEquals("GBP", $this->shop->getDefaultCurrency()); - $this->assertContains("EUR", $this->shop->getCurrencies()); - } - - /** - * @group shopobjects - */ - function testUsedCurrency() - { - // GIVEN - $this->givenShop(); - - // WHEN - $this->shop->setUsedCurrency("EUR"); - - // THEN - $this->assertEquals("EUR", $this->shop->getUsedCurrency()); - } - - /** - * @group shopobjects - */ - function testUsedLocale() - { - // GIVEN - $this->givenShop(); - - // WHEN - $this->shop->setUsedLocale("en_GB"); - - // THEN - $this->assertEquals("en_GB", $this->shop->getUsedLocale()); - } - - function givenShop() { - $this->shop = new Shop("sandbox.epages.com", "EpagesDevD20150929T075829R63", "icgToyl45PKhmkz6E2PUQOriaCoE5Wzq", true); - } - - function cleanUp() { - unset($this->shop); - } - -} - -?> \ No newline at end of file diff --git a/tests/shopobjects/address/AddressTest.php b/tests/shopobjects/address/AddressTest.php deleted file mode 100644 index 92f2855..0000000 --- a/tests/shopobjects/address/AddressTest.php +++ /dev/null @@ -1,133 +0,0 @@ -givenInvalidAddressParameter(); - - // WHEN - $address = new Address($invalidAddressParameter); - - // THEN - $this->assertTrue($address->error()); - $this->assertEquals($address->errorNumber(), "A-1"); - } - - /** - * @group shopobjects - */ - function testAcceptCompleteAddressParameter() { - // GIVEN - $completeAddressParameter = $this->givenCompleteAddressParameter(); - - // WHEN - $address = new Address($completeAddressParameter); - - // THEN - $this->assertFalse($address->error()); - $this->thenCompleteAddressInformationIsExisting($address); - } - - /** - * @group shopobjects - */ - function testAcceptIncompleteAddressParameter() { - // GIVEN - $incompleteAddressParameter = $this->givenIncompleteAddressParameter(); - - // WHEN - $address = new Address($incompleteAddressParameter); - - // THEN - $this->assertFalse($address->error()); - $this->assertNotNull($address->getBirthday()); - $this->assertNull($address->getCity()); - } - - /** - * @group shopobjects - */ - function testSetAddressParameters() { - // GIVEN - $incompleteAddressParameter = $this->givenIncompleteAddressParameter(); - - // WHEN - $address = new Address($incompleteAddressParameter); - $address->setBirthday("01.02.1900"); - $address->setCity("Cologne"); - $address->setCompany("FakeCompany"); - $address->setCountry("England"); - $address->setEmailAddress("a@b.cd"); - $address->setFirstName("Max"); - $address->setLastName("Miller"); - $address->setSalutation("Mr."); - $address->setState("NRW"); - $address->setStreet("First street 2"); - $address->setStreetDetails("c/o Mister Smith"); - $address->setTitle("Master"); - $address->setVatId("DE1234567890"); - $address->setZipCode("12345"); - - // THEN - $this->assertFalse($address->error()); - $this->thenCompleteAddressInformationIsExisting($address); - } - - function givenInvalidAddressParameter() { - return "SomeString"; - } - - function givenCompleteAddressParameter() { - return array( - "birthday" => "01.02.1900", - "city" => "Cologne", - "company" => "FakeCompany", - "country" => "England", - "emailAddress" => "a@b.cd", - "firstName" => "Max", - "lastName" => "Miller", - "salutation" => "Mr.", - "state" => "NRW", - "street" => "First street 2", - "streetDetails" => "c/o Mister Smith", - "title" => "Master", - "vatId" => "DE1234567890", - "zipCode" => "12345" - ); - } - - function givenIncompleteAddressParameter() { - return array( - "birthday" => "01.02.1900" - ); - } - - function thenCompleteAddressInformationIsExisting($address) { - $this->assertNotNull($address->getBirthday()); - $this->assertNotNull($address->getCity()); - $this->assertNotNull($address->getCompany()); - $this->assertNotNull($address->getCountry()); - $this->assertNotNull($address->getEmailAddress()); - $this->assertNotNull($address->getFirstName()); - $this->assertNotNull($address->getLastName()); - $this->assertNotNull($address->getSalutation()); - $this->assertNotNull($address->getState()); - $this->assertNotNull($address->getStreet()); - $this->assertNotNull($address->getStreetDetails()); - $this->assertNotNull($address->getTitle()); - $this->assertNotNull($address->getVatId()); - $this->assertNotNull($address->getZipCode()); - } - -} - -?> \ No newline at end of file diff --git a/tests/shopobjects/date/DateTest.php b/tests/shopobjects/date/DateTest.php deleted file mode 100644 index 42046b3..0000000 --- a/tests/shopobjects/date/DateTest.php +++ /dev/null @@ -1,59 +0,0 @@ -assertFalse($date->error()); - $this->assertEquals($date->getTimestamp(), 1477407378); - $this->assertEquals($date->asReadable(), "2016-10-25T14:56:18.000Z"); - } - - /** - * @group shopobjects - */ - function testCreateDateAsString() { - // GIVEN - $validString = "2016-10-25T14:56:18.000Z"; - - // WHEN - $date = new Date($validString); - - // THEN - $this->assertFalse($date->error()); - $this->assertEquals($date->getTimestamp(), 1477407378); - $this->assertEquals($date->asReadable(), "2016-10-25T14:56:18.000Z"); - } - - /** - * @group shopobjects - */ - function testRejectCreateDateNoString() { - // GIVEN - $invalidTimestamp = null; - - // WHEN - $date = new Date($invalidTimestamp); - - // THEN - $this->assertTrue($date->error()); - $this->assertEquals($date->errorNumber(), "D-1"); - } - -} - -?> \ No newline at end of file diff --git a/tests/shopobjects/information/ContactInformationTest.php b/tests/shopobjects/information/ContactInformationTest.php deleted file mode 100644 index 0498118..0000000 --- a/tests/shopobjects/information/ContactInformationTest.php +++ /dev/null @@ -1,39 +0,0 @@ -shop = new Shop("sandbox.epages.com", "EpagesDevD20150929T075829R63", "icgToyl45PKhmkz6E2PUQOriaCoE5Wzq", true); - $this->contactInformation = $this->shop->getContactInformation(); - } - - /** - * @group shopobjects - */ - function testContactInformation() - { - // THEN - $this->assertNotNull($this->contactInformation->getAddress()); - $this->assertNotNull($this->contactInformation->getDescription()); - $this->assertEquals("Contact information", $this->contactInformation->getName()); - $this->assertEquals("Contact information", $this->contactInformation->getNavigationCaption()); - $this->assertEquals("David David", $this->contactInformation->getContactPerson()); - $this->assertEquals("000000", $this->contactInformation->getPhone()); - $this->assertEquals("bepeppered@gmail.com", $this->contactInformation->getEmail()); - } - - function cleanUp() { - unset($this->shop); - } - -} - -?> \ No newline at end of file diff --git a/tests/shopobjects/information/PrivacyPolicyInformationTest.php b/tests/shopobjects/information/PrivacyPolicyInformationTest.php deleted file mode 100644 index 28029b8..0000000 --- a/tests/shopobjects/information/PrivacyPolicyInformationTest.php +++ /dev/null @@ -1,32 +0,0 @@ -shop = new Shop("sandbox.epages.com", "EpagesDevD20150929T075829R63", "icgToyl45PKhmkz6E2PUQOriaCoE5Wzq", true); - } - - /** - * @group shopobjects - */ - function testShopPrivacyPolicyInformation() - { - // THEN - $privacyPolicyInformation = $this->shop->getPrivacyPolicyInformation(); - $this->assertEquals("Privacy policy", $privacyPolicyInformation->getName()); - $this->assertEquals("Privacy policy", $privacyPolicyInformation->getNavigationCaption()); - } - - function cleanUp() { - unset($this->shop); - } - -} - -?> \ No newline at end of file diff --git a/tests/shopobjects/information/RightsOfWithdrawalInformationTest.php b/tests/shopobjects/information/RightsOfWithdrawalInformationTest.php deleted file mode 100644 index 7e7d9cd..0000000 --- a/tests/shopobjects/information/RightsOfWithdrawalInformationTest.php +++ /dev/null @@ -1,32 +0,0 @@ -shop = new Shop("sandbox.epages.com", "EpagesDevD20150929T075829R63", "icgToyl45PKhmkz6E2PUQOriaCoE5Wzq", true); - } - - /** - * @group shopobjects - */ - function testShopRightsOfWithdrawalInformation() - { - // THEN - $rightsOfWithdrawalInformation = $this->shop->getRightsOfWithdrawalInformation(); - $this->assertEquals("Right of withdrawal", $rightsOfWithdrawalInformation->getName()); - $this->assertEquals("Right of withdrawal", $rightsOfWithdrawalInformation->getNavigationCaption()); - } - - function cleanUp() { - unset($this->shop); - } - -} - -?> \ No newline at end of file diff --git a/tests/shopobjects/information/ShippingInformationTest.php b/tests/shopobjects/information/ShippingInformationTest.php deleted file mode 100644 index 2fa970a..0000000 --- a/tests/shopobjects/information/ShippingInformationTest.php +++ /dev/null @@ -1,32 +0,0 @@ -shop = new Shop("sandbox.epages.com", "EpagesDevD20150929T075829R63", "icgToyl45PKhmkz6E2PUQOriaCoE5Wzq", true); - } - - /** - * @group shopobjects - */ - function testShopShippingInformation() - { - // THEN - $shippingInformation = $this->shop->getShippingInformation(); - $this->assertEquals("Shipping terms", $shippingInformation->getName()); - $this->assertEquals("Delivery", $shippingInformation->getNavigationCaption()); - } - - function cleanUp() { - unset($this->shop); - } - -} - -?> \ No newline at end of file diff --git a/tests/shopobjects/information/TermsAndConditionInformationTest.php b/tests/shopobjects/information/TermsAndConditionInformationTest.php deleted file mode 100644 index b688032..0000000 --- a/tests/shopobjects/information/TermsAndConditionInformationTest.php +++ /dev/null @@ -1,33 +0,0 @@ -shop = new Shop("sandbox.epages.com", "EpagesDevD20150929T075829R63", "icgToyl45PKhmkz6E2PUQOriaCoE5Wzq", true); - } - - /** - * @group shopobjects - */ - function testShopTermsAndConditionInformation() - { - // THEN - $termsAndConditionInformation = $this->shop->getTermsAndConditionInformation(); - $this->assertEquals("Terms and Conditions", $termsAndConditionInformation->getName()); - $this->assertEquals("Terms and Conditions", $termsAndConditionInformation->getNavigationCaption()); - $this->assertEquals("You adapt this text via the preview or data sheet view under the \"Content/Categories\" menu item of your Administration.", $termsAndConditionInformation->getDescription()); - } - - function cleanUp() { - unset($this->shop); - } - -} - -?> \ No newline at end of file diff --git a/tests/shopobjects/method/PaymentMethodTest.php b/tests/shopobjects/method/PaymentMethodTest.php deleted file mode 100644 index 63886a4..0000000 --- a/tests/shopobjects/method/PaymentMethodTest.php +++ /dev/null @@ -1,95 +0,0 @@ -assertTrue($paymentMethod->error()); - $this->assertEquals($paymentMethod->errorNumber(), "PM-1"); - } - - /** - * @group shopobjects - */ - function testCreateCompletePaymentMethod() { - // GIVEN - $paymentMethodParameter = $this->givenCompletePaymentMethod(); - - // WHEN - $paymentMethod = new PaymentMethod($paymentMethodParameter); - - // THEN - echo $paymentMethod->errorNumber(); - $this->assertFalse($paymentMethod->error()); - $this->assertEquals($paymentMethod->getName(), "Paypal"); - $this->assertEquals($paymentMethod->getID(), "123456789"); - } - - /** - * @group shopobjects - */ - function testCreatePaymentMethodOnlyID() { - // GIVEN - $paymentMethodParameter = $this->givenPaymentMethodOnlyID(); - - // WHEN - $paymentMethod = new PaymentMethod($paymentMethodParameter); - - // THEN - $this->assertFalse($paymentMethod->error()); - $this->assertNull($paymentMethod->getName()); - $this->assertEquals($paymentMethod->getID(), "123456789"); - } - - /** - * @group shopobjects - */ - function testCreatePaymentMethodOnlyName() { - // GIVEN - $paymentMethodParameter = $this->givenPaymentMethodOnlyName(); - - // WHEN - $paymentMethod = new PaymentMethod($paymentMethodParameter); - - // THEN - $this->assertFalse($paymentMethod->error()); - $this->assertEquals($paymentMethod->getName(), "Paypal"); - $this->assertNull($paymentMethod->getID()); - } - - function givenCompletePaymentMethod() { - return array( - "id" => "123456789", - "name" => "Paypal" - ); - } - - function givenPaymentMethodOnlyID() { - return array( - "id" => "123456789" - ); - } - - function givenPaymentMethodOnlyName() { - return array( - "name" => "Paypal" - ); - } - -} - -?> \ No newline at end of file diff --git a/tests/shopobjects/method/ShippingMethodTest.php b/tests/shopobjects/method/ShippingMethodTest.php deleted file mode 100644 index 7ff3fbf..0000000 --- a/tests/shopobjects/method/ShippingMethodTest.php +++ /dev/null @@ -1,95 +0,0 @@ -assertTrue($shippingMethod->error()); - $this->assertEquals($shippingMethod->errorNumber(), "SM-1"); - } - - /** - * @group shopobjects - */ - function testCreateCompleteShippingMethod() { - // GIVEN - $shippingMethodParameter = $this->givenCompleteShippingMethod(); - - // WHEN - $shippingMethod = new ShippingMethod($shippingMethodParameter); - - // THEN - echo $shippingMethod->errorNumber(); - $this->assertFalse($shippingMethod->error()); - $this->assertEquals($shippingMethod->getName(), "DHL"); - $this->assertEquals($shippingMethod->getID(), "123456789"); - } - - /** - * @group shopobjects - */ - function testCreateShippingMethodOnlyID() { - // GIVEN - $shippingMethodParameter = $this->givenShippingMethodOnlyID(); - - // WHEN - $shippingMethod = new PaymentMethod($shippingMethodParameter); - - // THEN - $this->assertFalse($shippingMethod->error()); - $this->assertNull($shippingMethod->getName()); - $this->assertEquals($shippingMethod->getID(), "123456789"); - } - - /** - * @group shopobjects - */ - function testCreateShippingMethodOnlyName() { - // GIVEN - $shippingMethodParameter = $this->givenShippingMethodOnlyName(); - - // WHEN - $shippingMethod = new PaymentMethod($shippingMethodParameter); - - // THEN - $this->assertFalse($shippingMethod->error()); - $this->assertEquals($shippingMethod->getName(), "DHL"); - $this->assertNull($shippingMethod->getID()); - } - - function givenCompleteShippingMethod() { - return array( - "id" => "123456789", - "name" => "DHL" - ); - } - - function givenShippingMethodOnlyID() { - return array( - "id" => "123456789" - ); - } - - function givenShippingMethodOnlyName() { - return array( - "name" => "DHL" - ); - } - -} - -?> \ No newline at end of file diff --git a/tests/shopobjects/order/OrderTest.php b/tests/shopobjects/order/OrderTest.php deleted file mode 100644 index dc10d56..0000000 --- a/tests/shopobjects/order/OrderTest.php +++ /dev/null @@ -1,4 +0,0 @@ - \ No newline at end of file diff --git a/tests/util/InputValidatorTest.php b/tests/util/InputValidatorTest.php deleted file mode 100644 index ba8a37f..0000000 --- a/tests/util/InputValidatorTest.php +++ /dev/null @@ -1,306 +0,0 @@ -assertFalse(InputValidator::isArray(42)); - $this->assertFalse(InputValidator::isArray("String")); - $this->assertTrue(InputValidator::isArray(array())); - $this->assertTrue(InputValidator::isArray(array(1, 2, 3))); - } - - /** - * @group utility - */ - function testIsAuthToken() - { - $this->assertFalse(InputValidator::isAuthToken(null)); - $this->assertFalse(InputValidator::isAuthToken("")); - $this->assertTrue(InputValidator::isAuthToken("SomeString")); - } - - /** - * @group utility - */ - function testIsCurrency() - { - $this->assertFalse(InputValidator::isCurrency("")); - $this->assertFalse(InputValidator::isCurrency(123)); - $this->assertFalse(InputValidator::isCurrency("notvalid")); - $this->assertFalse(InputValidator::isCurrency("eur")); - $this->assertFalse(InputValidator::isCurrency("NotValid")); - $this->assertFalse(InputValidator::isCurrency("nv")); - $this->assertTrue(InputValidator::isCurrency("EUR")); - } - - /** - * @group utility - */ - function testIsEmpty() - { - $this->assertFalse(InputValidator::isEmpty("String")); - $this->assertFalse(InputValidator::isEmpty(123)); - $this->assertTrue(InputValidator::isEmpty("")); - $this->assertTrue(InputValidator::isEmpty(null)); - } - - /** - * @group utility - */ - function testIsEmptyArray() - { - $this->assertFalse(InputValidator::isEmptyArray("String")); - $this->assertFalse(InputValidator::isEmptyArray(array(1, 2, 3))); - $this->assertTrue(InputValidator::isEmptyArray(array())); - } - - /** - * @group utility - */ - function testIsEmptyArrayKey() - { - $this->assertTrue(InputValidator::isEmptyArrayKey(array(), "Key")); - $this->assertTrue(InputValidator::isEmptyArrayKey(array("String" => "Value"), "Key")); - $this->assertTrue(InputValidator::isEmptyArrayKey(array("String" => 123), "Key")); - $this->assertTrue(InputValidator::isEmptyArrayKey(array(123), "Key")); - $this->assertTrue(InputValidator::isEmptyArrayKey(array("String"), "Key")); - $this->assertTrue(InputValidator::isEmptyArrayKey(array("String", 123), "Key")); - $this->assertFalse(InputValidator::isEmptyArrayKey(array("Key" => "Value"), "Key")); - $this->assertFalse(InputValidator::isEmptyArrayKey(array("Key" => 123), "Key")); - $this->assertTrue(InputValidator::isEmptyArrayKey(array("Key" => null), "Key")); - $this->assertFalse(InputValidator::isEmptyArrayKey(array("Key" => ""), "Key")); - } - - /** - * @group utility - */ - function testIsFloat() - { - $this->assertFalse(InputValidator::isFloat("String")); - $this->assertFalse(InputValidator::isFloat(array())); - $this->assertFalse(InputValidator::isFloat(array(1.2))); - $this->assertFalse(InputValidator::isFloat(3)); - $this->assertFalse(InputValidator::isFloat(null)); - $this->assertTrue(InputValidator::isFloat(1.2)); - $this->assertTrue(InputValidator::isFloat(-1.2)); - } - - /** - * @group utility - */ - function testIsFormatterType() - { - $this->assertFalse(InputValidator::isFormatterType("NotAFormatterType")); - $this->assertTrue(InputValidator::isFormatterType("IMAGE")); - } - - /** - * @group utility - */ - function testIsHost() - { - $this->assertFalse(InputValidator::isHost("Not a host")); - $this->assertFalse(InputValidator::isHost(3)); - $this->assertFalse(InputValidator::isHost(null)); - $this->assertFalse(InputValidator::isHost(1.2)); - $this->assertTrue(InputValidator::isHost("www.google.com")); - $this->assertTrue(InputValidator::isHost("some.sub.domain-things.com")); - } - - /** - * @group utility - */ - function testIsInt() - { - $this->assertFalse(InputValidator::isInt("String")); - $this->assertFalse(InputValidator::isInt(array())); - $this->assertFalse(InputValidator::isInt(array(12))); - $this->assertTrue(InputValidator::isInt(3)); - $this->assertFalse(InputValidator::isInt(null)); - $this->assertFalse(InputValidator::isInt(1.2)); - $this->assertTrue(InputValidator::isInt(-3)); - } - - /** - * @group utility - */ - function testIsJSON() - { - $this->assertFalse(InputValidator::isJSON("Some String")); - $this->assertTrue(InputValidator::isJSON(3)); - $this->assertFalse(InputValidator::isJSON(null)); - $this->assertTrue(InputValidator::isJSON(1.2)); - $this->assertTrue(InputValidator::isJSON("{}")); - } - - /** - * @group utility - */ - function testIsLocale() - { - $this->assertFalse(InputValidator::isLocale("Some String")); - $this->assertFalse(InputValidator::isLocale(3)); - $this->assertFalse(InputValidator::isLocale(null)); - $this->assertFalse(InputValidator::isLocale(1.2)); - $this->assertFalse(InputValidator::isLocale("a_b")); - $this->assertFalse(InputValidator::isLocale("AB_de")); - $this->assertFalse(InputValidator::isLocale("dedede_DEDEDE")); - $this->assertTrue(InputValidator::isLocale("de_DE")); - $this->assertTrue(InputValidator::isLocale("abc_DE")); - } - - /** - * @group utility - */ - function testIsLogLevel() - { - $this->assertFalse(InputValidator::isLogLevel("Some String")); - $this->assertFalse(InputValidator::isLogLevel(3)); - $this->assertFalse(InputValidator::isLogLevel(null)); - $this->assertFalse(InputValidator::isLogLevel(1.2)); - $this->assertFalse(InputValidator::isLogLevel("notification")); - $this->assertTrue(InputValidator::isLogLevel("NOTIFICATION")); - } - - /** - * @group utility - */ - function testIsProductDirection() - { - $this->assertFalse(InputValidator::isProductDirection("Some String")); - $this->assertFalse(InputValidator::isProductDirection(3)); - $this->assertFalse(InputValidator::isProductDirection(null)); - $this->assertFalse(InputValidator::isProductDirection(1.2)); - $this->assertFalse(InputValidator::isProductDirection("ASC")); - $this->assertTrue(InputValidator::isProductDirection("asc")); - } - - /** - * @group utility - */ - function testIsProductId() - { - $this->assertFalse(InputValidator::isProductId(null)); - $this->assertFalse(InputValidator::isProductId("")); - $this->assertTrue(InputValidator::isProductId("SomeString")); - } - - /** - * @group utility - */ - function testIsProductSort() - { - $this->assertFalse(InputValidator::isProductSort("Some String")); - $this->assertFalse(InputValidator::isProductSort(3)); - $this->assertFalse(InputValidator::isProductSort(null)); - $this->assertFalse(InputValidator::isProductSort(1.2)); - $this->assertFalse(InputValidator::isProductSort("NAME")); - $this->assertTrue(InputValidator::isProductSort("name")); - } - - /** - * @group utility - */ - function testIsOutputRessource() - { - $this->assertFalse(InputValidator::isOutputRessource("Some String")); - $this->assertFalse(InputValidator::isOutputRessource(3)); - $this->assertFalse(InputValidator::isOutputRessource(null)); - $this->assertFalse(InputValidator::isOutputRessource(1.2)); - $this->assertFalse(InputValidator::isOutputRessource("screen")); - $this->assertTrue(InputValidator::isOutputRessource("SCREEN")); - } - - /** - * @group utility - */ - function testIsRangedFloat() - { - $this->assertFalse(InputValidator::isRangedFloat("Some String")); - $this->assertFalse(InputValidator::isRangedFloat(3)); - $this->assertFalse(InputValidator::isRangedFloat(null)); - $this->assertTrue(InputValidator::isRangedFloat(1.2)); - $this->assertTrue(InputValidator::isRangedFloat(1.2, 0.0)); - $this->assertFalse(InputValidator::isRangedFloat(1.2, 2.0)); - $this->assertTrue(InputValidator::isRangedFloat(1.2, 0.0, 12.0)); - $this->assertFalse(InputValidator::isRangedFloat(1.2, 2.0, 12.0)); - $this->assertTrue(InputValidator::isRangedFloat(1.2, null, 12.0)); - $this->assertFalse(InputValidator::isRangedFloat(1.2, null, -1.0)); - } - - /** - * @group utility - */ - function testIsRangedInt() - { - $this->assertFalse(InputValidator::isRangedInt("Some String")); - $this->assertTrue(InputValidator::isRangedInt(3)); - $this->assertFalse(InputValidator::isRangedInt(null)); - $this->assertFalse(InputValidator::isRangedInt(1.2)); - $this->assertTrue(InputValidator::isRangedInt(1, 0)); - $this->assertFalse(InputValidator::isRangedInt(1, 2)); - $this->assertTrue(InputValidator::isRangedInt(1, 0, 12)); - $this->assertFalse(InputValidator::isRangedInt(1, 2, 12)); - $this->assertTrue(InputValidator::isRangedInt(1, null, 12)); - $this->assertFalse(InputValidator::isRangedInt(1, null, -1)); - } - - /** - * @group utility - */ - function testIsRequestMethod() - { - $this->assertFalse(InputValidator::isRequestMethod("Some String")); - $this->assertFalse(InputValidator::isRequestMethod(3)); - $this->assertFalse(InputValidator::isRequestMethod(null)); - $this->assertFalse(InputValidator::isRequestMethod(1.2)); - $this->assertFalse(InputValidator::isRequestMethod("get")); - $this->assertTrue(InputValidator::isRequestMethod("GET")); - } - - /** - * @group utility - */ - function testIsShop() - { - $this->assertFalse(InputValidator::isShop(null)); - $this->assertFalse(InputValidator::isShop("")); - $this->assertTrue(InputValidator::isShop("SomeString")); - } - - /** - * @group utility - */ - function testIsString() - { - $this->assertTrue(InputValidator::isString("String")); - $this->assertFalse(InputValidator::isString(array())); - $this->assertFalse(InputValidator::isString(array(12))); - $this->assertFalse(InputValidator::isString(3)); - $this->assertFalse(InputValidator::isString(null)); - $this->assertFalse(InputValidator::isString(1.2)); - } - - /** - * @group utility - */ - function testIsTimestamp() - { - $this->assertFalse(InputValidator::isTimestamp("NoTimestamp")); - $this->assertTrue(InputValidator::isTimestamp(1234567890)); - } - -} - -?> \ No newline at end of file diff --git a/tests/util/RESTClientTest.php b/tests/util/RESTClientTest.php deleted file mode 100644 index 415b4e9..0000000 --- a/tests/util/RESTClientTest.php +++ /dev/null @@ -1,193 +0,0 @@ -assertTrue(RESTClient::connect("www.google.de", "Shopname")); - $this->assertTrue(RESTClient::connect("www.google.de", "Shopname", "AuthToken")); - $this->assertFalse(RESTClient::connect("ThisIsNODomain", "Shopname", "AuthToken")); - $this->assertTrue(RESTClient::connect("www.google.de", "Shopname", "AuthToken", true)); - $this->assertTrue(RESTClient::connect("www.google.de", "Shopname", "AuthToken", false)); - $this->assertTrue(RESTClient::disconnect()); - } - - /** - * @group utility - */ - function testGetContent() { - // GIVEN - RESTClient::connect("sandbox.epages.com", "EpagesDevD20150929T075829R63"); - - // WHEN - RESTClient::send("legal"); - - // THEN - $this->assertTrue(RESTClient::isResponseOk()); - $this->assertNotNull(RESTClient::getContent()); - $this->assertNotNull(RESTClient::getJSONContent()); - } - - /** - * @group utility - */ - function testGetContentWithLocalization() { - // GIVEN - RESTClient::connect("sandbox.epages.com", "EpagesDevD20150929T075829R63"); - - // WHEN - RESTClient::sendWithLocalization("legal", "de_DE"); - - // THEN - $this->assertTrue(RESTClient::isResponseOk()); - $this->assertNotNull(RESTClient::getContent()); - $this->assertNotNull(RESTClient::getJSONContent()); - } - - /** - * @group utility - */ - function testGetCookie() { - // GIVEN - RESTClient::connect("sandbox.epages.com", "EpagesDevD20150929T075829R63"); - - // WHEN - RESTClient::setCookie("testKey", "testValue"); - - // THEN - $this->assertNotEmpty(RESTClient::getCookies()); - $this->assertEquals(RESTClient::getCookie("testKey"), "testValue"); - } - - /** - * @group utility - */ - function testGetHeader() { - // GIVEN - RESTClient::connect("sandbox.epages.com", "EpagesDevD20150929T075829R63"); - - // WHEN - RESTClient::send("legal"); - - // THEN - $this->assertNotNull(RESTClient::getHeader("Date")); - } - - /** - * @group utility - */ - function testSetRequestMethod() - { - $this->assertFalse(RESTClient::setRequestMethod("NOVALIDMETHOD")); - $this->assertTrue(RESTClient::error()); - $this->assertEquals("RESTC-9", RESTClient::errorNumber()); - $this->assertTrue(RESTClient::setRequestMethod("GET")); - $this->assertTrue(RESTClient::setRequestMethod("PUT")); - $this->assertTrue(RESTClient::setRequestMethod("POST")); - $this->assertTrue(RESTClient::setRequestMethod("DELETE")); - $this->assertTrue(RESTClient::setRequestMethod("PATCH")); - } - - /** - * @group utility - */ - function testSend() - { - RESTClient::connect("sandbox.epages.com", "EpagesDevD20150929T075829R63", "icgToyl45PKhmkz6E2PUQOriaCoE5Wzq", true); - RESTClient::setRequestMethod("GET"); - RESTClient::send("locales", "NoArray"); - $this->assertTrue(RESTClient::error()); - $this->assertEquals("RESTC-5", RESTClient::errorNumber()); - - RESTClient::disconnect(); - RESTClient::send("locales"); - $this->assertTrue(RESTClient::error()); - $this->assertEquals("RESTC-6", RESTClient::errorNumber()); - - RESTClient::connect("sandbox.epages.com", "EpagesDevD20150929T075829R63", "icgToyl45PKhmkz6E2PUQOriaCoE5Wzq", true); - RESTClient::setRequestMethod("GET"); - RESTClient::send("NoValidRessource"); - $this->assertFalse(RESTClient::isResponseOk()); - $this->assertFalse(RESTClient::isResponseFound()); - - RESTClient::send(); - $this->assertTrue(RESTClient::isResponseOk()); - } - - /** - * @group utility - */ - function testSendWithLocalization() - { - RESTClient::connect("sandbox.epages.com", "EpagesDevD20150929T075829R63", "icgToyl45PKhmkz6E2PUQOriaCoE5Wzq", true); - RESTClient::setRequestMethod("GET"); - RESTClient::sendWithLocalization("locale", "NoLocale"); - $this->assertTrue(RESTClient::error()); - $this->assertEquals("RESTC-3", RESTClient::errorNumber()); - - RESTClient::sendWithLocalization("locales", "NoLocale", "NoArray"); - $this->assertTrue(RESTClient::error()); - $this->assertEquals("RESTC-3", RESTClient::errorNumber()); - - RESTClient::sendWithLocalization("locales", "en_GB", "NoArray"); - $this->assertTrue(RESTClient::error()); - $this->assertEquals("RESTC-5", RESTClient::errorNumber()); - - RESTClient::disconnect(); - RESTClient::sendWithLocalization("locales", "NoLocale"); - $this->assertTrue(RESTClient::error()); - $this->assertEquals("RESTC-3", RESTClient::errorNumber()); - - RESTClient::disconnect(); - RESTClient::sendWithLocalization("locales", "en_GB"); - $this->assertTrue(RESTClient::error()); - $this->assertEquals("RESTC-6", RESTClient::errorNumber()); - - RESTClient::connect("sandbox.epages.com", "EpagesDevD20150929T075829R63", "icgToyl45PKhmkz6E2PUQOriaCoE5Wzq", true); - RESTClient::setRequestMethod("GET"); - RESTClient::sendWithLocalization("NoValidRessource", "en_GB"); - $this->assertFalse(RESTClient::isResponseOk()); - $this->assertFalse(RESTClient::isResponseFound()); - - RESTClient::sendWithLocalization("NoValidRessource", "NoLocale"); - $this->assertTrue(RESTClient::error()); - $this->assertEquals("RESTC-3", RESTClient::errorNumber()); - - RESTClient::sendWithLocalization("locales", "de_DE", "noArray"); - $this->assertTrue(RESTClient::error()); - $this->assertEquals("RESTC-5", RESTClient::errorNumber()); - - RESTClient::sendWithLocalization("locales", "de_DE"); - $this->assertFalse(RESTClient::error()); - $this->assertNull(RESTClient::errorNumber()); - } - - /** - * @group utility - */ - function testSetRequestTime() - { - $this->assertFalse(RESTClient::setRequestWaitTime("NoInt")); - $this->assertTrue(RESTClient::error()); - $this->assertEquals("RESTC-10", RESTClient::errorNumber()); - - $this->assertFalse(RESTClient::setRequestWaitTime(-1)); - $this->assertTrue(RESTClient::error()); - $this->assertEquals("RESTC-10", RESTClient::errorNumber()); - - $this->assertTrue(RESTClient::setRequestWaitTime(600)); - $this->assertFalse(RESTClient::error()); - $this->assertNull(RESTClient::errorNumber()); - } -} \ No newline at end of file