diff --git a/.travis.yml b/.travis.yml index 67503a6..c907740 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,27 @@ language: php -sudo: true php: - - 5.3 - 5.4 - 5.5 - - 5.6 +# - 5.6 - 7.0 -env: - matrix: - - MAGENTO_VERSION="magento-mirror-1.6.2.0" INSTALL_SAMPLE_DATA=yes - - MAGENTO_VERSION="magento-mirror-1.7.0.2" INSTALL_SAMPLE_DATA=yes - - MAGENTO_VERSION="magento-mirror-1.8.1.0" INSTALL_SAMPLE_DATA=yes - # Do not download sample data of 1.9 -> The file is too big - - MAGENTO_VERSION="magento-mirror-1.9.0.1" INSTALL_SAMPLE_DATA=no - - MAGENTO_VERSION="magento-mirror-1.9.1.1" INSTALL_SAMPLE_DATA=no - - MAGENTO_VERSION="magento-mirror-1.9.2.1" INSTALL_SAMPLE_DATA=no - - MAGENTO_VERSION="magento-mirror-1.9.2.2" INSTALL_SAMPLE_DATA=no - - MAGENTO_VERSION="magento-mirror-1.9.2.3" INSTALL_SAMPLE_DATA=no - +## Update composer and run the appropriate composer command before_script: - - composer install - #install modman - #- sudo wget http://module-manager.googlecode.com/files/modman-1.1.1 - #- sudo cp modman-1.1.1 /usr/local/bin/modman - #- sudo chmod +x /usr/local/bin/modman #needs to be executable - #- cd "${MAGENTO_VERSION}" - #- modman init - #- modman deploy-all + - composer self-update -q + - if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi; + +before_install: + - chmod +x _deploy/travis.sh + +allow_failures: + - php: 5.4 + - php: hhvm + - env: MAGENTO_VERSION="magento-mirror-1.8.1.0" INSTALL_SAMPLE_DATA=yes + - env: MAGENTO_VERSION="magento-mirror-1.9.2.3" INSTALL_SAMPLE_DATA=yes + +env: + - MAGENTO_VERSION="magento-mirror-1.8.1.0" INSTALL_SAMPLE_DATA=no + - MAGENTO_VERSION="magento-mirror-1.9.2.3" INSTALL_SAMPLE_DATA=no -#script: -# - phpunit --coverage-text +script: _deploy/travis.sh \ No newline at end of file diff --git a/_deploy/.basedir b/_deploy/.basedir new file mode 100644 index 0000000..d476989 --- /dev/null +++ b/_deploy/.basedir @@ -0,0 +1 @@ +htdocs \ No newline at end of file diff --git a/_deploy/deploy_local.sh b/_deploy/deploy_local.sh new file mode 100644 index 0000000..cbf1360 --- /dev/null +++ b/_deploy/deploy_local.sh @@ -0,0 +1,97 @@ +#!/bin/bash +set -e +set -x + +function cleanup { + if [ -z $SKIP_CLEANUP ]; then + echo "Removing build directory ${BUILDENV}" + #rm -rf "${BUILDENV}" + fi +} + +trap cleanup EXIT + +BUILDENV="/srv/extension.vm"; + +MAGENTO_DB_HOST="127.0.0.1"; +MAGENTO_DB_PORT="3306"; +MAGENTO_DB_USER="super"; +MAGENTO_DB_PASS="super123"; +MAGENTO_DB_NAME="extension"; +MAGENTO_DB_ALLOWSAME="0"; + +CWD=$(pwd) + + +# Use the local mothership patched one +MAGENTO_VERSION=magento-mirror-1.8.1.0 + +# +if [ -d "${BUILDENV}/htdocs" ] ; then + rm -rf ${BUILDENV}/htdocs +fi + +mkdir -p ${BUILDENV}/htdocs + + +echo "Using build directory ${BUILDENV}" + + + +if [ -d "${BUILDENV}/.modman/extension" ] ; then + rm -rf "${BUILDENV}/.modman/extension" +fi + +mkdir -p ${BUILDENV}/.modman/extension + +cp -rf . "${BUILDENV}/.modman/extension" + +# Start building everything +cp -f ${CWD}/composer.json ${BUILDENV} +cp -f ${CWD}/_deploy/.basedir ${BUILDENV}/.modman + +# Get absolute path to main directory +ABSPATH=$(cd "${0%/*}" 2>/dev/null; echo "${PWD}/${0##*/}") +SOURCE_DIR=`dirname "${ABSPATH}"` + +echo ${SOURCE_DIR} + +echo +echo "-------------------------------" +echo "- Mothership local deployment -" +echo "-------------------------------" +echo + +cd /tmp + +mysql -u${MAGENTO_DB_USER} -p${MAGENTO_DB_PASS} -h${MAGENTO_DB_HOST} -P${MAGENTO_DB_PORT} -e "DROP DATABASE IF EXISTS \`${MAGENTO_DB_NAME}\`; CREATE DATABASE \`${MAGENTO_DB_NAME}\`;" + +# Install Magento with sample data +magerun install \ + --dbHost="${MAGENTO_DB_HOST}" --dbUser="${MAGENTO_DB_USER}" --dbPass="${MAGENTO_DB_PASS}" --dbName="${MAGENTO_DB_NAME}" --dbPort="${MAGENTO_DB_PORT}" \ + --installSampleData=yes \ + --useDefaultConfigParams=yes \ + --magentoVersionByName="${MAGENTO_VERSION}" \ + --installationFolder="${BUILDENV}/htdocs" \ + --baseUrl="http://extension.vm/" || { echo "Installing Magento failed"; exit 1; } + + +cd ${BUILDENV} + +php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php +php composer-setup.php + +php composer.phar install +modman deploy-all --force + +# After running composer, we will have all the files needed. Now +#cp ${CWD}/phpunit.xml.dist "${BUILDENV}/htdocs/phpunit.xml.dist" + +magerun cache:clean +magerun sys:module:list |grep Mothership + +export N98_MAGERUN_TEST_MAGENTO_ROOT=${BUILDENV}/htdocs + +cd ${BUILDENV}/htdocs +phpunit --group Mothership --debug --verbose + diff --git a/_deploy/reload.sh b/_deploy/reload.sh new file mode 100644 index 0000000..e11b1ba --- /dev/null +++ b/_deploy/reload.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e +set -x + + +BUILDENV="/srv/extension.vm"; + +cp -f composer.json ${BUILDENV} +cp -f _deploy/.basedir ${BUILDENV}/.modman + +if [ -d "${BUILDENV}/.modman/extension" ] ; then + rm -rf "${BUILDENV}/.modman/extension" +fi + +cp -rf . "${BUILDENV}/.modman/extension" + +cd ${BUILDENV} +php composer.phar install +modman deploy-all --force + +magerun cache:clean +magerun sys:module:list |grep Mothership +export N98_MAGERUN_TEST_MAGENTO_ROOT=${BUILDENV}/htdocs \ No newline at end of file diff --git a/_deploy/travis.sh b/_deploy/travis.sh new file mode 100644 index 0000000..1411de4 --- /dev/null +++ b/_deploy/travis.sh @@ -0,0 +1,104 @@ +#!/bin/bash +set -e +set -x + +# most of the script is based on the fantastic https://github.com/AOEpeople/MageTestStand project + +# create a temporary directory +BUILDENV=`mktemp -d /tmp/mothership.XXXXXXXX` +CWD=$(pwd) + +echo "BUILD = ${BUILDENV}" +echo "CWD = ${CWD}" + + +mkdir -p ${BUILDENV}/.modman/mothership_magerun + +cp -rf . "${BUILDENV}/.modman/mothership_magerun" + +# Start building everything +cp -f ${CWD}/composer.json ${BUILDENV} +cp -f ${CWD}/_deploy/.basedir ${BUILDENV}/.modman + +# Get absolute path to main directory +ABSPATH=$(cd "${0%/*}" 2>/dev/null; echo "${PWD}/${0##*/}") +SOURCE_DIR=`dirname "${ABSPATH}"` + +if [ -z $MAGENTO_DB_HOST ]; then MAGENTO_DB_HOST="localhost"; fi +if [ -z $MAGENTO_DB_PORT ]; then MAGENTO_DB_PORT="3306"; fi +if [ -z $MAGENTO_DB_USER ]; then MAGENTO_DB_USER="root"; fi +if [ -z $MAGENTO_DB_PASS ]; then MAGENTO_DB_PASS=""; fi +if [ -z $MAGENTO_DB_NAME ]; then MAGENTO_DB_NAME="mageteststand"; fi +if [ -z $MAGENTO_DB_ALLOWSAME ]; then MAGENTO_DB_ALLOWSAME="0"; fi + +echo +echo "---------------------" +echo "- Mothership local -" +echo "---------------------" +echo +echo "Installing ${MAGENTO_VERSION} in ${SOURCE_DIR}/htdocs" +echo "using Database Credentials:" +echo " Host: ${MAGENTO_DB_HOST}" +echo " Port: ${MAGENTO_DB_PORT}" +echo " User: ${MAGENTO_DB_USER}" +echo " Pass: [hidden]" +echo " Main DB: ${MAGENTO_DB_NAME}" +echo " Test DB: ${MAGENTO_DB_NAME}_test" +echo " Allow same db: ${MAGENTO_DB_ALLOWSAME}" +echo + + + + +cd ${BUILDENV} + +# Download composer +composer self-update +bash < <(curl -s -L https://raw.github.com/colinmollenhour/modman/master/modman-installer) + +cd ${BUILDENV} +wget http://files.magerun.net/n98-magerun-latest.phar +chmod +x ./n98-magerun-latest.phar + + +if [ ! -f htdocs/app/etc/local.xml ] ; then + + # Create main database + MYSQLPASS="" + if [ ! -z $MAGENTO_DB_PASS ]; then MYSQLPASS="-p${MAGENTO_DB_PASS}"; fi + mysql -u${MAGENTO_DB_USER} ${MYSQLPASS} -h${MAGENTO_DB_HOST} -P${MAGENTO_DB_PORT} -e "DROP DATABASE IF EXISTS \`${MAGENTO_DB_NAME}\`; CREATE DATABASE \`${MAGENTO_DB_NAME}\`;" + + ./n98-magerun-latest.phar install \ + --dbHost="${MAGENTO_DB_HOST}" --dbUser="${MAGENTO_DB_USER}" --dbPass="${MAGENTO_DB_PASS}" --dbName="${MAGENTO_DB_NAME}" --dbPort="${MAGENTO_DB_PORT}" \ + --installSampleData=yes \ + --useDefaultConfigParams=yes \ + --magentoVersionByName="${MAGENTO_VERSION}" \ + --installationFolder="${BUILDENV}/htdocs" \ + --baseUrl="http://magento.local/" || { echo "Installing Magento failed"; exit 1; } +fi + +# run composer update and install all requirements +composer self-update +composer install + +# run modman and first debug +ls -lisah ${BUILDENV} +modman deploy-all --force + +./n98-magerun-latest.phar --root-dir=htdocs config:set dev/template/allow_symlink 1 +./n98-magerun-latest.phar --root-dir=htdocs sys:setup:run +./n98-magerun-latest.phar --root-dir=htdocs cache:flush + +./n98-magerun-latest.phar cache:clean +./n98-magerun-latest.phar sys:module:list +export N98_MAGERUN_TEST_MAGENTO_ROOT=${BUILDENV}/htdocs + + +cd ${BUILDENV}/htdocs +ls -lisah ${BUILDENV}/htdocs + +ls -lisah ${BUILDENV}/vendor/ +cat ${BUILDENV}/vendor/autoload.php +cat ${BUILDENV}/vendor/composer/autoload_psr4.php + +../vendor/phpunit/phpunit/phpunit --verbose --debug --config=phpunit.xml \ No newline at end of file diff --git a/composer.json b/composer.json index ef103f5..3ec6c40 100644 --- a/composer.json +++ b/composer.json @@ -7,18 +7,21 @@ "require": { "php": ">=5.4", "magento-hackathon/magento-composer-installer": "*", - "symfony/yaml": "2.7", - "mothership/state_machine": ">=v1.0 <2.0", + "symfony/yaml": "~2.7", + "mothership/state_machine": "v1.1.*", "firegento/psr0autoloader": "dev-master" }, "require-dev": { "phpunit/phpunit": "~4.8", - "escapestudios/symfony2-coding-standard": "~2.0" + "escapestudios/symfony2-coding-standard": "~2.0", + "n98/magerun": "dev-master", + "composer/composer": "1.0.*@dev", + "aoepeople/composer-installers": "*" }, "repositories": [ { "type": "composer", - "url": "http://packages.firegento.com" + "url": "https://packages.firegento.com/" } ], "authors": [ @@ -30,10 +33,15 @@ ], "autoload": { "psr-4": { - "Mothership\\Magerun\\": "www/lib/Mothership/Magerun" + "Mothership\\Magerun\\": "htdocs/lib/Mothership/Magerun" + } + }, + "autoload-dev": { + "psr-4": { + "Mothership\\Magerun\\Base\\": ["htdocs/lib/n98-magerun/modules/mothership_addons/src", "htdocs/tests/Mothership/Magerun/Base"] } }, "extra": { - "magento-root-dir": "root" + "magento-root-dir": "htdocs" } } diff --git a/modman b/modman index d4d6875..1eda4b0 100644 --- a/modman +++ b/modman @@ -1,10 +1,15 @@ src/lib/n98-magerun/modules/mothership_addons lib/n98-magerun/modules/mothership_addons src/app/etc/mothership/environments/environment_vm.php.example app/etc/mothership/environments/environment_vm.php.example +src/app/etc/mothership/workflows/Example.yaml app/etc/mothership/workflows/Example.yaml + src/app/etc/modules/Mothership_Addons.xml app/etc/modules/Mothership_Addons.xml src/app/code/local/Mothership/Addons app/code/local/Mothership/Addons src/media/feeds/readme.md media/feeds/readme.md src/lib/Mothership/Magerun lib/Mothership/Magerun -src/shell/queue.php shell/queue.php \ No newline at end of file +src/shell/queue.php shell/queue.php + +tests tests +phpunit.xml.dist phpunit.xml \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..4e7d9f1 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,33 @@ + + + + ./tests + tests/N98/Magento/Command/Installer/UninstallCommandTest.php + + + ./tests/N98/Magento/Command/Installer/UninstallCommandTest.php + + + + + ./src + + tests/bootstrap.php + + + + \ No newline at end of file diff --git a/readme.md b/readme.md index 4719d17..d5f3936 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,14 @@ #Mothership Magerun Addons -![](https://travis-ci.org/mothership-gmbh/magerun_mothership.svg?branch=develop) +![](https://travis-ci.org/mothership-gmbh/magerun_mothership.svg) + + +[![Dependency Status](https://www.versioneye.com/user/projects/56d70789d71695003e63118a/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56d70789d71695003e63118a) +[![Latest Stable Version](https://poser.pugx.org/mothership/mothership_magerun/v/stable)](https://packagist.org/packages/mothership/mothership_magerun) +[![Total Downloads](https://poser.pugx.org/mothership/mothership_magerun/downloads)](https://packagist.org/packages/mothership/mothership_magerun) +[![Latest Unstable Version](https://poser.pugx.org/mothership/mothership_magerun/v/unstable)](https://packagist.org/packages/mothership/mothership_magerun) +[![License](https://poser.pugx.org/mothership/mothership_magerun/license)](https://packagist.org/packages/mothership/mothership_magerun) + ========================= This repository contains a list of extensions, which might be useful for your development workflow. diff --git a/src/app/etc/mothership/workflows/Example.yaml b/src/app/etc/mothership/workflows/Example.yaml new file mode 100644 index 0000000..fc810e3 --- /dev/null +++ b/src/app/etc/mothership/workflows/Example.yaml @@ -0,0 +1,87 @@ +#class of the model +class: + name: Mothership\Magerun\Workflows\Example + args: [] + +#definition of the states and transition...the order establishes the transition from one state to another +#the name of each state is NOT case sensitive +states: + + # initialize the logging and stuff + start: + type: initial + + second_state: + type: normal + transitions_from: [start] + transitions_to: [second_state] + + load_document: + type: normal + transitions_from: [second_state] + transitions_to: [load_document] + + has_images: + type: normal + transitions_from: [load_document] + transitions_to: [has_images] + + download_directory_exist: + type: normal + transitions_from: [has_images] + transitions_to: [download_directory_exist] + + product_has_media_gallery: + type: normal + transitions_from: [download_directory_exist] + transitions_to: [product_has_media_gallery] + + create_media_gallery: + type: normal + transitions_from: [{status: product_has_media_gallery, result: false}] + transitions_to: [create_media_gallery] + + get_images: + type: normal + transitions_from: [{status: product_has_media_gallery, result: true}, create_media_gallery] + transitions_to: [get_images] + + process_images: + type: normal + transitions_from: [get_images, {status: has_more, result: true}] + transitions_to: [process_images] + + original_image_exist_as_copy: + type: normal + transitions_from: [process_images] + transitions_to: [original_image_exist_as_copy] + + hash_equals_original: + type: normal + transitions_from: [{status: original_image_exist_as_copy, result: true}] + transitions_to: [copy_equals_original] + + remove_existing: + type: normal + transitions_from: [{status: hash_equals_original, result: false}] + transitions_to: [is_new] + + download_original: + type: normal + transitions_from: [{status: original_image_exist_as_copy, result: false}, remove_existing] + transitions_to: [download_original] + + assign_image: + type: normal + transitions_from: [{status: hash_equals_original, result: true}, download_original] + transitions_to: [assign_image] + + has_more: + type: normal + transitions_from: [assign_image] + transitions_to: [has_more] + + finish: + type: final + transitions_from: [{status: has_more, result: false}] + transitions_to: [finish] \ No newline at end of file diff --git a/src/lib/Mothership/Magerun/Workflows/Example.php b/src/lib/Mothership/Magerun/Workflows/Example.php new file mode 100644 index 0000000..023e9f8 --- /dev/null +++ b/src/lib/Mothership/Magerun/Workflows/Example.php @@ -0,0 +1,149 @@ + + * @copyright 2016 Mothership GmbH + * + * @link http://www.mothership.de/ + * + * Use this job for a general purpose + * + */ +class Example extends WorkflowAbstract +{ + public function second_state() + { + } + + public function load_document() + { + } + + /** + * If there is no image, throw an exception. + * + * + * @throws \Exception + */ + public function has_images() + { + } + + /** + * If the download directory does not exist, then create it. + */ + public function download_directory_exist() + { + } + + /** + * Every product needs to have a media gallery. + * + * @return bool + */ + public function product_has_media_gallery() + { + return (rand(0, 1) == 1) ? true : false; + } + + /** + * Create the media gallery. + */ + public function create_media_gallery() + { + } + + /** + * Get all images and set the pointer to the first item. + */ + public function get_images() + { + //$this->_collection = end($this->_images->parse($this->_document)); + for ($i = 0; $i <= 100; ++$i) { + $this->_collection[] = ['test']; + } + $this->_pointer = 0; + } + + /** + * Set the pointer to the current image. + */ + public function process_images() + { + } + + /** + * Check that the current image exist as a copy. + * + * @return bool + */ + public function original_image_exist_as_copy() + { + return (rand(0, 1) == 1) ? true : false; + } + + /** + * The image also needs to have the same checksum and the original one. + * + * @return bool + * + * @throws \Exception + */ + public function hash_equals_original() + { + return (rand(0, 1) == 1) ? true : false; + } + + /** + * Remove existing images. + */ + public function remove_existing() + { + } + + /** + * Download from the Intex FTP. + * + * + * @throws \Exception + */ + public function download_original() + { + } + + public function assign_image_straight() + { + } + + public function assign_image() + { + } + + public function has_more() + { + if ($this->_pointer + 1 == count($this->_collection)) { + return false; + } + ++$this->_pointer; + + return true; + } + + public function finish() + { + } +} diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Workflow/RunCommand.php b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Workflow/RunCommand.php index 7dd79ce..5d63d30 100644 --- a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Workflow/RunCommand.php +++ b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Workflow/RunCommand.php @@ -136,7 +136,7 @@ protected function configure() * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output */ - protected function interact($input, $output) + protected function interact(InputInterface $input, OutputInterface $output) { if ($input->hasOption('interactive') && $input->getOption('interactive')) { @@ -204,8 +204,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->printCommand($args, $output); // TODO: Check if queue is enabled - \Resque::setBackend(\Mage::getStoreConfig('mothership_intex/queue/host')); - \Resque::enqueue(\Mage::getStoreConfig('mothership_intex/queue/name'), '\Mothership\Magerun\Queue\Jobs\General', $args, true); + \Resque::setBackend(\Mage::getStoreConfig('mothership_magerun/queue/host')); + \Resque::enqueue(\Mage::getStoreConfig('mothership_magerun/queue/name'), '\Mothership\Magerun\Queue\Jobs\General', $args, true); } else { $stateMachine = new \Mothership\StateMachine\StateMachine($input_path . '/' . $filename); $stateMachine->run($this->getArguments($input, $output)); diff --git a/tests/Mothership/Magerun/Base/Command/Environment/EnvironmentsTest.php b/tests/Mothership/Magerun/Base/Command/Environment/EnvironmentsTest.php new file mode 100644 index 0000000..95af93c --- /dev/null +++ b/tests/Mothership/Magerun/Base/Command/Environment/EnvironmentsTest.php @@ -0,0 +1,24 @@ +markTestSkipped('Not used at the moment'); + $application = $this->getApplication(); + $application->add(new DumpCommand()); + $command = $this->getApplication()->find('mothership:base:environment:dump'); + + $commandTester = new CommandTester($command); + $commandTester->execute(['command' => $command->getName()]); + + $this->assertContains('Cache config cleaned', $commandTester->getDisplay()); + } +} \ No newline at end of file diff --git a/tests/Mothership/Magerun/Base/Command/PHPUnit/TestCase.php b/tests/Mothership/Magerun/Base/Command/PHPUnit/TestCase.php new file mode 100644 index 0000000..cf726ea --- /dev/null +++ b/tests/Mothership/Magerun/Base/Command/PHPUnit/TestCase.php @@ -0,0 +1,51 @@ +application === null) { + $root = $this->getTestMagentoRoot(); + + $this->application = $this->getMock( + 'N98\Magento\Application', + array('getMagentoRootFolder') + ); + $loader = require __DIR__ . '/../../../../../../../../vendor/autoload.php'; + $this->application->setAutoloader($loader); + $this->application->expects($this->any())->method('getMagentoRootFolder')->will($this->returnValue($root)); + + spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload')); + + $this->application->init(); + $this->application->initMagento(); + if ($this->application->getMagentoMajorVersion() == Application::MAGENTO_MAJOR_VERSION_1) { + spl_autoload_unregister(array(\Varien_Autoload::instance(), 'autoload')); + } + } + + return $this->application; + } +} \ No newline at end of file diff --git a/tests/Mothership/Magerun/Base/Command/Workflow/ListCommandTest.php b/tests/Mothership/Magerun/Base/Command/Workflow/ListCommandTest.php new file mode 100644 index 0000000..c5523e7 --- /dev/null +++ b/tests/Mothership/Magerun/Base/Command/Workflow/ListCommandTest.php @@ -0,0 +1,37 @@ + + * @copyright 2016 Mothership GmbH + * + * @link http://www.mothership.de/ + */ +class ListCommandTest extends TestCase +{ + public function testExecute() + { + $this->markTestSkipped('Interactive'); + $application = $this->getApplication(); + $application->add(new ListCommand()); + $command = $this->getApplication()->find('mothership:base:workflow:run'); + + $commandTester = new CommandTester($command); + $commandTester->execute(['command' => $command->getName(), 'config' => 'Demo.yaml']); + + $this->assertContains('Cache config cleaned', $commandTester->getDisplay()); + } +} diff --git a/tests/Mothership/Magerun/Base/Command/Workflow/RunCommandTest.php b/tests/Mothership/Magerun/Base/Command/Workflow/RunCommandTest.php new file mode 100644 index 0000000..e502838 --- /dev/null +++ b/tests/Mothership/Magerun/Base/Command/Workflow/RunCommandTest.php @@ -0,0 +1,36 @@ + + * @copyright 2016 Mothership GmbH + * + * @link http://www.mothership.de/ + */ +class RunCommandTest extends TestCase +{ + public function testExecute() + { + $application = $this->getApplication(); + $application->add(new ListCommand()); + $command = $this->getApplication()->find('mothership:base:workflow:run'); + + $commandTester = new CommandTester($command); + $commandTester->execute(['command' => $command->getName(), '--config' => 'Example.yaml']); + + $this->assertContains('Option "Example.yaml" set', $commandTester->getDisplay()); + } +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..6fe9e98 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,21 @@ + +setUseIncludePath(true); +$paths = array( + $base.'/app/code/local', + $base.'/app/code/community', + $base.'/app/code/core', + $base.'/lib', +); +set_include_path(implode(PATH_SEPARATOR, $paths).PATH_SEPARATOR.get_include_path()); +unset($paths, $base);