From 81425fd784bcd3a22da3e9f70d40657bcd9569b8 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 11:00:12 +0200 Subject: [PATCH 01/17] Added initial travis config. (bunq/sdk_php#126) --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..513b4834 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: php +php: + - 7.0.13 + - 7.1 + - 7.2 +install: composer install +script: vendor/bin/paratest -p 2 From c2c5778ffaae90b65185c6e51b49b0ae78ed12f5 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 11:11:43 +0200 Subject: [PATCH 02/17] Automatic install return ApiContext and only save when needed. (bunq/sdk_php#126) --- src/Util/InstallationUtil.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Util/InstallationUtil.php b/src/Util/InstallationUtil.php index a03b22fa..bd69c63b 100644 --- a/src/Util/InstallationUtil.php +++ b/src/Util/InstallationUtil.php @@ -116,14 +116,18 @@ public static function interactiveInstall() /** * @param BunqEnumApiEnvironmentType $environmentType - * @param string $contextFileName + * @param string|null $contextFileName * @param string|null $apiKey + * @param bool $saveToConfFile + * + * @return ApiContext */ public static function automaticInstall( BunqEnumApiEnvironmentType $environmentType, - string $contextFileName, - string $apiKey = null - ) { + string $contextFileName = null, + string $apiKey = null, + bool $saveToConfFile = false + ): ApiContext { try { $context = static::createApiContextWithoutConstructor(); @@ -166,11 +170,11 @@ public static function automaticInstall( ); $methodInitializeSessionContext->invoke($context); - if ($contextFileName === null) { - $context->save(); - } else { + if (!$contextFileName === null && $saveToConfFile) { $context->save($contextFileName); } + + return $context; } catch (BunqException $exception) { echo sprintf(self::ERROR_BUNQ_EXCEPTION, $exception->getMessage()); var_dump($exception); From 7e5ce59a250af37fd55e0aada95dca2154286670 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 11:12:38 +0200 Subject: [PATCH 03/17] Use the ApiContext returned from the auto install. (bunq/sdk_php#126) --- tests/BunqSdkTestBase.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/BunqSdkTestBase.php b/tests/BunqSdkTestBase.php index a86addb1..1ebcb0b3 100644 --- a/tests/BunqSdkTestBase.php +++ b/tests/BunqSdkTestBase.php @@ -88,19 +88,17 @@ class BunqSdkTestBase extends TestCase */ public static function setUpBeforeClass() { - static::createApiContext(); BunqContext::loadApiContext( - ApiContext::restore(self::FILE_PATH_CONTEXT_CONFIG) + static::createApiContext() ); } /** */ - protected static function createApiContext() + protected static function createApiContext(): ApiContext { - InstallationUtil::automaticInstall( - BunqEnumApiEnvironmentType::SANDBOX(), - self::FILE_PATH_CONTEXT_CONFIG + return InstallationUtil::automaticInstall( + BunqEnumApiEnvironmentType::SANDBOX() ); } From 55d197f893b3861a82afb9f581253b9f90010a01 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 11:13:21 +0200 Subject: [PATCH 04/17] Ran auto formatter. (bunq/sdk_php#126) --- tests/BunqSdkTestBase.php | 112 +++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/tests/BunqSdkTestBase.php b/tests/BunqSdkTestBase.php index 1ebcb0b3..3743fd8e 100644 --- a/tests/BunqSdkTestBase.php +++ b/tests/BunqSdkTestBase.php @@ -67,6 +67,13 @@ class BunqSdkTestBase extends TestCase */ const INDEX_FIRST = 0; + /** + * Spending money constants. + */ + const SPENDING_MONEY_AMOUNT = '500'; + const SPENDING_MONEY_RECIPIENT = 'sugardaddy@bunq.com'; + const SPENDING_MONEY_DESCRIPTION = 'sdk php test, thanks daddy <3'; + /** * @var MonetaryAccountBank */ @@ -77,13 +84,6 @@ class BunqSdkTestBase extends TestCase */ protected $cashRegister; - /** - * Spending money constants. - */ - const SPENDING_MONEY_AMOUNT = '500'; - const SPENDING_MONEY_RECIPIENT = 'sugardaddy@bunq.com'; - const SPENDING_MONEY_DESCRIPTION = 'sdk php test, thanks daddy <3'; - /** */ public static function setUpBeforeClass() @@ -112,43 +112,6 @@ protected function setUp() BunqContext::getUserContext()->refreshUserContext(); } - /** - */ - private function setCashRegister() - { - $attachmentUuid = AttachmentPublic::create( - FileUtil::getFileContents(__DIR__ . self::FILE_PATH_AVATAR), - [ - ApiClient::HEADER_CONTENT_TYPE => $this->getAttachmentContentType(), - ApiClient::HEADER_ATTACHMENT_DESCRIPTION => $this->getAttachmentDescription(), - ] - ); - $avatarUuid = Avatar::create($attachmentUuid->getValue()); - $cashRegisterId = CashRegister::create( - self::CASH_REGISTER_NAME, - self::CASH_REGISTER_STATUS, - $avatarUuid->getValue() - ); - - $this->cashRegister = CashRegister::get($cashRegisterId->getValue()); - } - - /** - * @return string - */ - protected function getAttachmentContentType(): string - { - return self::ATTACHMENT_CONTENT_TYPE; - } - - /** - * @return string - */ - protected function getAttachmentDescription(): string - { - return self::ATTACHMENT_DESCRIPTION; - } - /** */ private function setSecondMonetaryAccountBank() @@ -181,6 +144,14 @@ private function requestSpendingMoney() ); } + /** + * @return int + */ + protected function getSecondMonetaryAccountId(): int + { + return $this->secondMonetaryAccountBank->getId(); + } + /** * @return Pointer * @@ -234,14 +205,6 @@ protected function getPointerUserBravo(): Pointer ); } - /** - * @return int - */ - protected function getSecondMonetaryAccountId(): int - { - return $this->secondMonetaryAccountBank->getId(); - } - /** * @return int */ @@ -255,13 +218,40 @@ protected function getCashRegisterId(): int } /** - * @return bool */ - protected function isMonetaryAccountBalanceSufficient(): bool + private function setCashRegister() { - $balance = floatval(BunqContext::getUserContext()->getPrimaryMonetaryAccount()->getBalance()->getValue()); + $attachmentUuid = AttachmentPublic::create( + FileUtil::getFileContents(__DIR__ . self::FILE_PATH_AVATAR), + [ + ApiClient::HEADER_CONTENT_TYPE => $this->getAttachmentContentType(), + ApiClient::HEADER_ATTACHMENT_DESCRIPTION => $this->getAttachmentDescription(), + ] + ); + $avatarUuid = Avatar::create($attachmentUuid->getValue()); + $cashRegisterId = CashRegister::create( + self::CASH_REGISTER_NAME, + self::CASH_REGISTER_STATUS, + $avatarUuid->getValue() + ); - return $balance > self::MONETARY_ACCOUNT_BALANCE_THRESHOLD; + $this->cashRegister = CashRegister::get($cashRegisterId->getValue()); + } + + /** + * @return string + */ + protected function getAttachmentContentType(): string + { + return self::ATTACHMENT_CONTENT_TYPE; + } + + /** + * @return string + */ + protected function getAttachmentDescription(): string + { + return self::ATTACHMENT_DESCRIPTION; } /** @@ -275,4 +265,14 @@ protected function skipTestIfNeededDueToInsufficientBalance(): bool return true; } + + /** + * @return bool + */ + protected function isMonetaryAccountBalanceSufficient(): bool + { + $balance = floatval(BunqContext::getUserContext()->getPrimaryMonetaryAccount()->getBalance()->getValue()); + + return $balance > self::MONETARY_ACCOUNT_BALANCE_THRESHOLD; + } } From 776a39ddbabfc409359c949700630f8b7d5a6373 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 11:19:16 +0200 Subject: [PATCH 05/17] Throw the exception instead of catching it during auto install. (bunq/sdk_php#126) --- src/Util/InstallationUtil.php | 129 ++++++++++++++++------------------ 1 file changed, 60 insertions(+), 69 deletions(-) diff --git a/src/Util/InstallationUtil.php b/src/Util/InstallationUtil.php index bd69c63b..068cab42 100644 --- a/src/Util/InstallationUtil.php +++ b/src/Util/InstallationUtil.php @@ -114,75 +114,6 @@ public static function interactiveInstall() } } - /** - * @param BunqEnumApiEnvironmentType $environmentType - * @param string|null $contextFileName - * @param string|null $apiKey - * @param bool $saveToConfFile - * - * @return ApiContext - */ - public static function automaticInstall( - BunqEnumApiEnvironmentType $environmentType, - string $contextFileName = null, - string $apiKey = null, - bool $saveToConfFile = false - ): ApiContext { - try { - $context = static::createApiContextWithoutConstructor(); - - if (is_null($environmentType)) { - $environmentType = BunqEnumApiEnvironmentType::SANDBOX(); - } else { - // Environment already passed - } - - static::setPrivateProperty($context, self::PROPERTY_ENVIRONMENT_TYPE, $environmentType); - - if ($environmentType->equals(BunqEnumApiEnvironmentType::SANDBOX()) && is_null($apiKey)) { - $methodCreateSandboxUser = static::createAccessibleReflectionMethod( - ApiContext::class, - self::METHOD_CREATE_SANDBOX_USER - ); - - $methodCreateSandboxUser->invoke($context); - } elseif (!is_null($apiKey)) { - static::setPrivateProperty($context, self::PROPERTY_API_KEY, $apiKey); - } else { - throw new BunqException(self::ERROR_CANNOT_CREATE_API_KEY_PRODUCTION); - } - - $methodInitializeInstallationContext = static::createAccessibleReflectionMethod( - ApiContext::class, - self::METHOD_INITIALIZE_INSTALLATION_CONTEXT - ); - $methodInitializeInstallationContext->invoke($context); - - $methodRegisterDevice = static::createAccessibleReflectionMethod( - ApiContext::class, - self::METHOD_REGISTER_DEVICE - ); - $methodRegisterDevice->invoke($context, gethostname(), []); - - $methodInitializeSessionContext = static::createAccessibleReflectionMethod( - ApiContext::class, - self::METHOD_INITIALIZE_SESSION_CONTEXT - ); - $methodInitializeSessionContext->invoke($context); - - if (!$contextFileName === null && $saveToConfFile) { - $context->save($contextFileName); - } - - return $context; - } catch (BunqException $exception) { - echo sprintf(self::ERROR_BUNQ_EXCEPTION, $exception->getMessage()); - var_dump($exception); - } catch (Exception $exception) { - echo sprintf(self::ERROR_EXCEPTION, $exception->getMessage()); - } - } - /** * @return ApiContext */ @@ -291,4 +222,64 @@ private static function assertIpIsValid(string $ip) throw new BunqException(self::ERROR_INVALID_IP_ADDRESS, [$ip]); } } + + /** + * @param BunqEnumApiEnvironmentType $environmentType + * @param string|null $contextFileName + * @param string|null $apiKey + * @param bool $saveToConfFile + * + * @return ApiContext + */ + public static function automaticInstall( + BunqEnumApiEnvironmentType $environmentType, + string $contextFileName = null, + string $apiKey = null, + bool $saveToConfFile = false + ): ApiContext { + $context = static::createApiContextWithoutConstructor(); + + if (!is_null($environmentType)) { + $environmentType = BunqEnumApiEnvironmentType::SANDBOX(); + } + + static::setPrivateProperty($context, self::PROPERTY_ENVIRONMENT_TYPE, $environmentType); + + if ($environmentType->equals(BunqEnumApiEnvironmentType::SANDBOX()) && is_null($apiKey)) { + $methodCreateSandboxUser = static::createAccessibleReflectionMethod( + ApiContext::class, + self::METHOD_CREATE_SANDBOX_USER + ); + + $methodCreateSandboxUser->invoke($context); + } elseif (!is_null($apiKey)) { + static::setPrivateProperty($context, self::PROPERTY_API_KEY, $apiKey); + } else { + throw new BunqException(self::ERROR_CANNOT_CREATE_API_KEY_PRODUCTION); + } + + $methodInitializeInstallationContext = static::createAccessibleReflectionMethod( + ApiContext::class, + self::METHOD_INITIALIZE_INSTALLATION_CONTEXT + ); + $methodInitializeInstallationContext->invoke($context); + + $methodRegisterDevice = static::createAccessibleReflectionMethod( + ApiContext::class, + self::METHOD_REGISTER_DEVICE + ); + $methodRegisterDevice->invoke($context, gethostname(), []); + + $methodInitializeSessionContext = static::createAccessibleReflectionMethod( + ApiContext::class, + self::METHOD_INITIALIZE_SESSION_CONTEXT + ); + $methodInitializeSessionContext->invoke($context); + + if (!$contextFileName === null && $saveToConfFile) { + $context->save($contextFileName); + } + + return $context; + } } From 09972f71bf582be12000d6db7ee047e01c1b6d5b Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 11:19:50 +0200 Subject: [PATCH 06/17] Minor refactor. (bunq/sdk_php#126) --- src/Util/InstallationUtil.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Util/InstallationUtil.php b/src/Util/InstallationUtil.php index 068cab42..161a5cd5 100644 --- a/src/Util/InstallationUtil.php +++ b/src/Util/InstallationUtil.php @@ -64,10 +64,12 @@ public static function interactiveInstall() try { $context = static::createApiContextWithoutConstructor(); - $environmentType = new BunqEnumApiEnvironmentType(static::readLine( - self::PROMPT_ENVIRONMENT, - self::ERROR_EMPTY_ENVIRONMENT - )); + $environmentType = new BunqEnumApiEnvironmentType( + static::readLine( + self::PROMPT_ENVIRONMENT, + self::ERROR_EMPTY_ENVIRONMENT + ) + ); static::setPrivateProperty($context, self::PROPERTY_ENVIRONMENT_TYPE, $environmentType); $apiKey = static::readLine( From 8169b193cf1bd774350fbb689bc77f8e277daff8 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 11:32:12 +0200 Subject: [PATCH 07/17] Update curl to latest version when running tests on travis. (bunq/sdk_php#126) --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index 513b4834..d9b71765 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,16 @@ php: - 7.1 - 7.2 install: composer install +before_script: + - apt-get build-dep curl + - cd /tmp + - wget https://curl.haxx.se/download/curl-7.59.0.tar.bz2 + - tar -xvjf curl-7.59.0.tar.bz2 + - cd curl-7.59.0 + - ./configure + - make + - make install + - ldconfig + - curl --version + script: vendor/bin/paratest -p 2 From 2dc7310e536c420c2fafb3b33380f5b828562811 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 11:34:42 +0200 Subject: [PATCH 08/17] Run commands as root. (bunq/sdk_php#126) --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9b71765..afb8df67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,14 +5,14 @@ php: - 7.2 install: composer install before_script: - - apt-get build-dep curl + - sudo apt-get build-dep curl - cd /tmp - wget https://curl.haxx.se/download/curl-7.59.0.tar.bz2 - tar -xvjf curl-7.59.0.tar.bz2 - cd curl-7.59.0 - ./configure - make - - make install + - sudo make install - ldconfig - curl --version From a4b2ee13de89ebf8ce192872f28225e06d22de23 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 11:39:45 +0200 Subject: [PATCH 09/17] Added sudo at ldconfig command. (bunq/sdk_php#126) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index afb8df67..fbf00271 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ before_script: - ./configure - make - sudo make install - - ldconfig + - sudo ldconfig - curl --version script: vendor/bin/paratest -p 2 From 18df2d609af8fa114445c565aec1b6a06c46de34 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 11:53:09 +0200 Subject: [PATCH 10/17] cd back to the project dir after curl update. (bunq/sdk_php#126) --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index fbf00271..ec11a11c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,5 +15,6 @@ before_script: - sudo make install - sudo ldconfig - curl --version + - cd ~/bunq/sdk_php script: vendor/bin/paratest -p 2 From 12fe75f0193d0be59148ac091379668ad8f4a35c Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 12:04:27 +0200 Subject: [PATCH 11/17] Fixed back cding. (bunq/sdk_php#126) --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ec11a11c..72ee1c36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ php: install: composer install before_script: - sudo apt-get build-dep curl - - cd /tmp + - pushd /tmp - wget https://curl.haxx.se/download/curl-7.59.0.tar.bz2 - tar -xvjf curl-7.59.0.tar.bz2 - cd curl-7.59.0 @@ -15,6 +15,6 @@ before_script: - sudo make install - sudo ldconfig - curl --version - - cd ~/bunq/sdk_php + - popd script: vendor/bin/paratest -p 2 From c42dfa4c9cd1130836e855ba33548c1e7596dc74 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 13:00:55 +0200 Subject: [PATCH 12/17] Install php-curl. (bunq/sdk_php#126) --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 72ee1c36..4c0d2675 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ php: install: composer install before_script: - sudo apt-get build-dep curl + - sudo apt-get install php-curl - pushd /tmp - wget https://curl.haxx.se/download/curl-7.59.0.tar.bz2 - tar -xvjf curl-7.59.0.tar.bz2 From 36f1aa803c20bf1c5d7f465abe58acf48bb69ce6 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 13:06:17 +0200 Subject: [PATCH 13/17] Added php repo. (bunq/sdk_php#126) --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4c0d2675..fe46336b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ php: - 7.2 install: composer install before_script: + - sudo apt-get install -y language-pack-en-base + - sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php + - apt update - sudo apt-get build-dep curl - sudo apt-get install php-curl - pushd /tmp From 1dcf9c1bdf7fe9946a990b56978aa49ea94bd484 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 13:40:08 +0200 Subject: [PATCH 14/17] Enabled debug mode. (bunq/sdk_php#126) --- .travis.yml | 4 ---- src/Http/ApiClient.php | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index fe46336b..72ee1c36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,11 +5,7 @@ php: - 7.2 install: composer install before_script: - - sudo apt-get install -y language-pack-en-base - - sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php - - apt update - sudo apt-get build-dep curl - - sudo apt-get install php-curl - pushd /tmp - wget https://curl.haxx.se/download/curl-7.59.0.tar.bz2 - tar -xvjf curl-7.59.0.tar.bz2 diff --git a/src/Http/ApiClient.php b/src/Http/ApiClient.php index c42725df..9a52c067 100644 --- a/src/Http/ApiClient.php +++ b/src/Http/ApiClient.php @@ -334,7 +334,7 @@ private function determineRequestOptions($body, array $customHeaders): array return [ self::OPTION_HEADERS => $headers, self::OPTION_BODY => $this->determineBodyString($body), - self::OPTION_DEBUG => false, + self::OPTION_DEBUG => true, self::OPTION_HTTP_ERRORS => false, ]; } From 64df7a00cf63f8d3016ebf78309582d7c0f2acb9 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 13:49:48 +0200 Subject: [PATCH 15/17] Revert "Enabled debug mode. (bunq/sdk_php#126)" This reverts commit 1dcf9c1bdf7fe9946a990b56978aa49ea94bd484. --- .travis.yml | 4 ++++ src/Http/ApiClient.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 72ee1c36..fe46336b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,11 @@ php: - 7.2 install: composer install before_script: + - sudo apt-get install -y language-pack-en-base + - sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php + - apt update - sudo apt-get build-dep curl + - sudo apt-get install php-curl - pushd /tmp - wget https://curl.haxx.se/download/curl-7.59.0.tar.bz2 - tar -xvjf curl-7.59.0.tar.bz2 diff --git a/src/Http/ApiClient.php b/src/Http/ApiClient.php index 9a52c067..c42725df 100644 --- a/src/Http/ApiClient.php +++ b/src/Http/ApiClient.php @@ -334,7 +334,7 @@ private function determineRequestOptions($body, array $customHeaders): array return [ self::OPTION_HEADERS => $headers, self::OPTION_BODY => $this->determineBodyString($body), - self::OPTION_DEBUG => true, + self::OPTION_DEBUG => false, self::OPTION_HTTP_ERRORS => false, ]; } From f531bd0048986b0a949f454bf3582a2316106d76 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 13:50:02 +0200 Subject: [PATCH 16/17] Use curl 57. (bunq/sdk_php#126) --- .travis.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index fe46336b..a6f3d116 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,16 +5,12 @@ php: - 7.2 install: composer install before_script: - - sudo apt-get install -y language-pack-en-base - - sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php - - apt update - sudo apt-get build-dep curl - - sudo apt-get install php-curl - pushd /tmp - - wget https://curl.haxx.se/download/curl-7.59.0.tar.bz2 - - tar -xvjf curl-7.59.0.tar.bz2 - - cd curl-7.59.0 - - ./configure + - wget https://curl.haxx.se/download/curl-7.57.0.tar.bz2 + - tar -xvjf curl-7.57.0.tar.bz2 + - cd curl-7.57.0 + - ./configure --with-ssl - make - sudo make install - sudo ldconfig From 9e218f7d0f279b005a1aea307197b590ce88144f Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Fri, 6 Apr 2018 15:27:54 +0200 Subject: [PATCH 17/17] Use docker to run tests. (bunq/sdk_php#126) --- .travis.yml | 27 +++++++------------ Dockerfile | 10 +++++++ .../Generated/Object/NotificationUrlTest.php | 2 +- 3 files changed, 20 insertions(+), 19 deletions(-) create mode 100644 Dockerfile diff --git a/.travis.yml b/.travis.yml index a6f3d116..ab57f9f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,11 @@ +sudo: required + language: php -php: - - 7.0.13 - - 7.1 - - 7.2 -install: composer install -before_script: - - sudo apt-get build-dep curl - - pushd /tmp - - wget https://curl.haxx.se/download/curl-7.57.0.tar.bz2 - - tar -xvjf curl-7.57.0.tar.bz2 - - cd curl-7.57.0 - - ./configure --with-ssl - - make - - sudo make install - - sudo ldconfig - - curl --version - - popd -script: vendor/bin/paratest -p 2 +services: + - docker + +before_install: + - docker build -t sdk . + +script: docker run sdk diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..50df9070 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM ubuntu:16.04 + +RUN apt update && apt install -y php7.0 php7.0-curl php7.0-mbstring php7.0-xml composer wget tar bzip2 zip + +RUN mkdir /sdk_php +COPY . /sdk_php +WORKDIR /sdk_php +RUN composer install + +CMD vendor/bin/paratest -p 1 \ No newline at end of file diff --git a/tests/Model/Generated/Object/NotificationUrlTest.php b/tests/Model/Generated/Object/NotificationUrlTest.php index 8547fb60..da8d5cb4 100644 --- a/tests/Model/Generated/Object/NotificationUrlTest.php +++ b/tests/Model/Generated/Object/NotificationUrlTest.php @@ -55,7 +55,7 @@ class NotificationUrlTest extends BunqSdkTestBase /** * Model json paths constants. */ - const BASE_PATH_JSON_MODEL = __DIR__ . '/../../../Resource/NotificationUrlJsons'; + const BASE_PATH_JSON_MODEL = __DIR__ . '../../../Resource/NotificationUrlJsons'; const JSON_PATH_MUTATION_MODEL = self::BASE_PATH_JSON_MODEL . '/Mutation.json'; const JSON_PATH_BUNQ_ME_TAB_MODEL = self::BASE_PATH_JSON_MODEL . '/BunqMeTab.json'; const JSON_PATH_CHAT_MESSAGE_ANNOUNCEMENT_MODEL = self::BASE_PATH_JSON_MODEL . '/ChatMessageAnnouncement.json';