diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5ef1caf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +language: php + +sudo: false + +env: + global: + - DB_USER=root + - DB_HOST=localhost + - DB_NAME=magento2_test + - ADMIN_FIRSTNAME=admin_firstname + - ADMIN_LASTNAME=admin_lastname + - ADMIN_EMAIL=example@email.com + - ADMIN_USER=admin + - ADMIN_PASS=admin123 + +matrix: + include: + - php: 7.0 + env: BRANCH=2.2-develop + +before_script: + - bash bin/install.sh + +script: + - cd ../magento2 + - php vendor/phpunit/phpunit/phpunit -c dev/tests/unit/phpunit.xml.dist app/code/Retailcrm/Retailcrm/Test/Unit/ diff --git a/bin/install.sh b/bin/install.sh new file mode 100644 index 0000000..bded0b6 --- /dev/null +++ b/bin/install.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +if [ -z $TRAVIS_BUILD_DIR ]; then + exit 0; +fi + +MAGE_ROOT=$TRAVIS_BUILD_DIR/../magento2 + +create_db() { + mysqladmin create magento_test --user="$DB_USER" --password="$DB_PASS" +} + +magento_clone() { + cd .. + git clone https://github.com/magento/magento2 + cd magento2 + git checkout $BRANCH + composer install + composer require retailcrm/api-client-php +} + +magento_install() { + cd $MAGE_ROOT + + php bin/magento setup:install \ + --db-host="$DB_HOST" \ + --db-name="$DB_NAME" \ + --db-user="$DB_USER" \ + --db-password="$DB_PASS" \ + --admin-firstname="$ADMIN_FIRSTNAME" \ + --admin-lastname="$ADMIN_LASTNAME" \ + --admin-email="$ADMIN_EMAIL" \ + --admin-user="$ADMIN_USER" \ + --admin-password="$ADMIN_PASS" \ + --language="en_US" \ + --currency="USD" \ + --timezone="Europe/Moscow" +} + +module_install() { + cd $MAGE_ROOT + mkdir -p app/code/Retailcrm/Retailcrm + cp -R $TRAVIS_BUILD_DIR/src/* app/code/Retailcrm/Retailcrm + + php bin/magento module:enable Retailcrm_Retailcrm + php bin/magento setup:upgrade + php bin/magento setup:di:compile +} + +create_db +magento_clone +magento_install +module_install diff --git a/Api/ConfigManagerInterface.php b/src/Api/ConfigManagerInterface.php similarity index 100% rename from Api/ConfigManagerInterface.php rename to src/Api/ConfigManagerInterface.php diff --git a/ApiClient/ApiClientFactory.php b/src/ApiClient/ApiClientFactory.php similarity index 100% rename from ApiClient/ApiClientFactory.php rename to src/ApiClient/ApiClientFactory.php diff --git a/Block/Adminhtml/System/Config/Button.php b/src/Block/Adminhtml/System/Config/Button.php similarity index 100% rename from Block/Adminhtml/System/Config/Button.php rename to src/Block/Adminhtml/System/Config/Button.php diff --git a/Block/Adminhtml/System/Config/Form/Field/Attributes.php b/src/Block/Adminhtml/System/Config/Form/Field/Attributes.php similarity index 100% rename from Block/Adminhtml/System/Config/Form/Field/Attributes.php rename to src/Block/Adminhtml/System/Config/Form/Field/Attributes.php diff --git a/Block/Adminhtml/System/Config/Form/Field/ListMode.php b/src/Block/Adminhtml/System/Config/Form/Field/ListMode.php similarity index 100% rename from Block/Adminhtml/System/Config/Form/Field/ListMode.php rename to src/Block/Adminhtml/System/Config/Form/Field/ListMode.php diff --git a/Block/Adminhtml/System/Config/Form/Field/Payment.php b/src/Block/Adminhtml/System/Config/Form/Field/Payment.php similarity index 89% rename from Block/Adminhtml/System/Config/Form/Field/Payment.php rename to src/Block/Adminhtml/System/Config/Form/Field/Payment.php index 5f03640..9448ebf 100644 --- a/Block/Adminhtml/System/Config/Form/Field/Payment.php +++ b/src/Block/Adminhtml/System/Config/Form/Field/Payment.php @@ -45,14 +45,14 @@ class Payment extends \Magento\Config\Block\System\Config\Form\Field return $htmlError; } - foreach (array_keys($activePaymentMethods) as $k => $payment) { + foreach ($activePaymentMethods as $code => $payment) { $html .= '