Skip to content
This repository has been archived by the owner on May 27, 2023. It is now read-only.

Commit

Permalink
! Add Travis build information + new shell commands
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanChepurnyi committed Feb 3, 2013
1 parent 2b9963d commit 9b85f00
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 118 deletions.
25 changes: 25 additions & 0 deletions .travis.yml
@@ -0,0 +1,25 @@
language: php
php:
- 5.3
- 5.4
env:
- MAGE=1.7.0.2
- MAGE=1.6.2.0
- MAGE=1.5.1.0
before_script:
# Fixing Magento hackathon installer
- mkdir -p tests/magento
# Installing required composer packages
- composer update --dev
# Installing magento version with prepared DB dump
- bin/mage-ci install tests/magento $MAGE magento -c -t -r http://mage-ci.ecomdev.org
# Installing EcomDev_PHPUnit module
- bin/mage-ci install-module tests/magento $(pwd)
# Configuring EcomDev_PHPUnit module
- CURRENT_DIR=$(pwd)
- cd tests/magento/shell
- php ecomdev-phpunit.php -a magento-config --db-name magento --same-db 1 --base_url http://test.magento.com/
- php ecomdev-phpunit.php -a change-status --enable
- cd $CURRENT_DIR
script:
- bin/mage-ci phpunit tests/magento --colors --coverage-text
36 changes: 21 additions & 15 deletions app/code/community/EcomDev/PHPUnit/Model/Config.php
Expand Up @@ -236,13 +236,20 @@ public function loadModules()
protected function _loadTestConfig()
{
$merge = clone $this->_prototype;
if ($merge->loadFile($this->_getLocalXmlForTest())) {
$this->_checkDbCredentialForDuplicate($this, $merge);
$this->_checkBaseUrl($this, $merge);
$this->extend($merge);
} else {
throw new Exception('Unable to load local.xml.phpunit');

try {
if ($merge->loadFile($this->_getLocalXmlForTest())) {
$this->_checkDbCredentialForDuplicate($this, $merge);
$this->_checkBaseUrl($this, $merge);
$this->extend($merge);
} else {
throw new RuntimeException('Unable to load local.xml.phpunit. Please run ecomdev-phpunit.php with install action.');
}
} catch (RuntimeException $e) {
echo $e->getMessage() . "\n";
exit(1);
}

return $this;
}

Expand Down Expand Up @@ -275,8 +282,10 @@ protected function _checkDbCredentialForDuplicate($original, $test)
$originalDbName = (string) $original->getNode('global/resources/default_setup/connection/dbname');
$testDbName = (string) $test->getNode('global/resources/default_setup/connection/dbname');

if ($originalDbName == $testDbName) {
throw new RuntimeException('Test DB cannot be the same as the live one');
if ($originalDbName == $testDbName && (string)$test->getNode('phpunit/allow_same_db') !== '1') {
throw new RuntimeException('Test DB cannot be the same as the live one. '
. 'You can change this option by running ecomdev-phpunit.php with'
. ' magento-config action.');
}
return $this;
}
Expand All @@ -296,12 +305,8 @@ protected function _checkBaseUrl($original, $test)

if (empty($baseUrlSecure) || empty($baseUrlUnsecure)
|| $baseUrlSecure == self::CHANGE_ME || $baseUrlUnsecure == self::CHANGE_ME) {
echo sprintf(
'Please change values in %s file for nodes %s and %s. '
. 'It will help in setting up proper controller test cases',
'app/etc/local.xml.phpunit', self::XML_PATH_SECURE_BASE_URL, self::XML_PATH_UNSECURE_BASE_URL
);
exit();
throw new RuntimeException('The base url is not set for proper controller tests. '
. 'Please run ecomdev-phpunit.php with magento-config action.');
}
}

Expand All @@ -316,7 +321,8 @@ protected function _getLocalXmlForTest()
{
$filePath = $this->getOptions()->getEtcDir() . DS . 'local.xml.phpunit';
if (!file_exists($filePath)) {
throw new RuntimeException('There is no local.xml.phpunit file');
throw new RuntimeException('There is no local.xml.phpunit file. '
. 'Try running ecomdev-phpunit.php with install action.');
}

return $filePath;
Expand Down
3 changes: 3 additions & 0 deletions app/etc/local.xml.phpunit
Expand Up @@ -25,4 +25,7 @@
</url>
</web>
</default>
<phpunit>
<allow_same_db>0</allow_same_db>
</phpunit>
</config>
8 changes: 7 additions & 1 deletion composer.json
Expand Up @@ -8,9 +8,15 @@
"magento-hackathon/magento-composer-installer": "*",
"phpunit/phpunit": "3.7.*"
},
"require-dev": {
"ecomdev/mage-ci": "dev-master"
},
"authors":[
{
"name":"Ivan Chepurnyi"
}
]
],
"extra": {
"magento-root-dir": "tests/magento"
}
}
9 changes: 6 additions & 3 deletions modman
@@ -1,10 +1,13 @@
# EcomDev_PHPUnit definition
app/etc/modules/EcomDev_*.xml app/etc/modules/
app/etc/modules/*.xml app/etc/modules/
app/code/community/EcomDev/* app/code/community/EcomDev/
lib/EcomDev/* lib/EcomDev/
lib/Spyc lib/Spyc
lib/vfsStream lib/vfsStream
shell/ecomdev-phpunit-install.php shell/ecomdev-phpunit-install.php
shell/*.php shell/

# Run shell installer
@shell cd $PROJECT/shell && php -f ecomdev-phpunit-install.php -- --module $MODULE --project $PROJECT
@shell cd $PROJECT/shell && php -f ecomdev-phpunit.php -- --action install

# Disables built in tests for extension
@shell cd $PROJECT/shell && php -f ecomdev-phpunit.php -- --action change-status
1 change: 1 addition & 0 deletions phpunit.xml.dist
Expand Up @@ -27,6 +27,7 @@
<directory suffix=".php">lib/EcomDev/Utils</directory>
<directory suffix=".php">lib/EcomDev/PHPUnit</directory>
<directory suffix=".php">lib/Spyc</directory>
<directory suffix=".php">lib/vfsStream</directory>
<!-- Exclude Mage.php file from code coverage -->
<file>app/Mage.php</file>
<!-- Exclude template files -->
Expand Down
99 changes: 0 additions & 99 deletions shell/ecomdev-phpunit-install.php

This file was deleted.

0 comments on commit 9b85f00

Please sign in to comment.