-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from AmpersandHQ/add-automated-travis-tests
Add automated travis tests and cherry pick #10
- Loading branch information
Showing
25 changed files
with
496 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
vendor/ | ||
composer.lock | ||
.php_cs.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
language: php | ||
php: 7.3 | ||
|
||
env: | ||
- TEST_GROUP=latest | ||
- TEST_GROUP=two_three_three | ||
|
||
install: | ||
# Composer install | ||
- composer install --no-interaction | ||
# Do a quick code style check | ||
- ./vendor/bin/php-cs-fixer fix --dry-run --rules=@PSR2 --diff src/ | ||
# Install magento | ||
- if [[ $TEST_GROUP = two_three_three ]]; then NAME=disablestockres VERSION=2.3.3 . ./vendor/bin/travis-install-magento.sh; fi | ||
- if [[ $TEST_GROUP = latest ]]; then NAME=disablestockres . ./vendor/bin/travis-install-magento.sh; fi | ||
# Install this module | ||
- cd vendor/ampersand/travis-vanilla-magento/instances/disablestockres | ||
- export COMPOSER_MEMORY_LIMIT=-1 | ||
- composer config repo.disablestockres git "../../../../../" | ||
- composer require ampersand/magento2-disable-stock-reservation dev-$TRAVIS_BRANCH || composer require ampersand/magento2-disable-stock-reservation $TRAVIS_BRANCH | ||
- php bin/magento setup:upgrade | ||
# compile magento | ||
- php bin/magento setup:di:compile | ||
# Set up test configuration | ||
- magerun2 config:store:set checkout/options/guest_checkout 1 | ||
- magerun2 config:store:set payment/checkmo/active 1 | ||
- magerun2 integration:create disablestockres [email protected] https://example.com --access-token="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | ||
- magerun2 cache:flush | ||
# warm caches | ||
- php bin/magento | ||
- cd - | ||
|
||
before_install: | ||
- mkdir -p $HOME/bin/ | ||
# Install magerun2 | ||
- test -f $HOME/bin/magerun2 || (wget https://files.magerun.net/n98-magerun2-latest.phar && chmod +x n98-magerun2-latest.phar && mv n98-magerun2-latest.phar $HOME/bin/magerun2) | ||
|
||
script: | ||
- ADDITIONAL_ARGS="-v" | ||
- if [[ $TRAVIS_COMMIT_MESSAGE == *"VERBOSE"* ]]; then ADDITIONAL_ARGS="-vvv"; fi; | ||
- ./vendor/bin/codecept build -c dev | ||
- URL="https://magento-disablestockres.localhost/" MYSQL_USER="root" MYSQL_HOST="127.0.0.1" MYSQL_DB="databasedisablestockres" MYSQL_PORT="3306" ./vendor/bin/codecept run acceptance -c dev $ADDITIONAL_ARGS | ||
|
||
addons: | ||
apt: | ||
packages: | ||
- postfix | ||
- apache2 | ||
- libapache2-mod-fastcgi | ||
|
||
services: | ||
- mysql | ||
|
||
cache: | ||
apt: true | ||
directories: | ||
- $HOME/.composer/cache | ||
- $HOME/bin | ||
|
||
after_failure: | ||
- test -d ./vendor/ampersand/travis-vanilla-magento/instances/disablestockres/var/report/ && for r in ./vendor/ampersand/travis-vanilla-magento/instances/disablestockres/var/report/*; do cat $r; done | ||
- test -f ./vendor/ampersand/travis-vanilla-magento/instances/disablestockres/var/log/system.log && grep -v "Broken reference" ./vendor/ampersand/travis-vanilla-magento/instances/disablestockres/var/log/system.log | ||
- test -f ./vendor/ampersand/travis-vanilla-magento/instances/disablestockres/var/log/exception.log && cat ./vendor/ampersand/travis-vanilla-magento/instances/disablestockres/var/log/exception.log | ||
- test -f ./vendor/ampersand/travis-vanilla-magento/instances/disablestockres/var/log/support_report.log && grep -v "Broken reference" ./vendor/ampersand/travis-vanilla-magento/instances/disablestockres/var/log/support_report.log | ||
- sleep 10; # give log files time to render |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
**Do not run these tests in production, they delete from and insert into your database as well as generate an integration token.** | ||
|
||
To run these tests locally you will need to | ||
|
||
1. Install a vanilla magento instance locally | ||
2. Install this module | ||
3. `magerun2 config:store:set checkout/options/guest_checkout 1` | ||
4. `magerun2 config:store:set payment/checkmo/active 1` | ||
5. `magerun2 integration:create disablestockres [email protected] https://example.com --access-token="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"` | ||
6. `magerun2 cache:flush` | ||
7. Run with the appropriate environment vars set, | ||
|
||
``` | ||
URL="https://magento-disablestockres.localhost/" MYSQL_USER="root" MYSQL_HOST="127.0.0.1" MYSQL_DB="databasedisablestockres" MYSQL_PORT="3306" ./dev/run-codeception.sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
paths: | ||
tests: tests | ||
output: tests/_output | ||
data: tests/_data | ||
support: tests/_support | ||
envs: tests/_envs | ||
actor_suffix: Tester | ||
settings: | ||
colors: true | ||
memory_limit: 1024M | ||
extensions: | ||
enabled: | ||
- Codeception\Extension\RunFailed | ||
params: | ||
- env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIR_BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
$DIR_BASE/../vendor/bin/codecept build -c dev | ||
$DIR_BASE/../vendor/bin/codecept run acceptance -c dev $1 -vvv |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
|
||
/** | ||
* Inherited Methods | ||
* @method void wantToTest($text) | ||
* @method void wantTo($text) | ||
* @method void execute($callable) | ||
* @method void expectTo($prediction) | ||
* @method void expect($prediction) | ||
* @method void amGoingTo($argumentation) | ||
* @method void am($role) | ||
* @method void lookForwardTo($achieveValue) | ||
* @method void comment($description) | ||
* @method void pause() | ||
* | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
class AcceptanceTester extends \Codeception\Actor | ||
{ | ||
use _generated\AcceptanceTesterActions; | ||
|
||
/** | ||
* Define custom actions here | ||
*/ | ||
use \Codeception\Lib\Actor\Shared\Retry; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
namespace Helper; | ||
|
||
// here you can define custom actions | ||
// all public methods declared in helper class will be available in $I | ||
use Codeception\Exception\ModuleException; | ||
use Symfony\Component\BrowserKit\Cookie; | ||
|
||
class Acceptance extends \Codeception\Module | ||
{ | ||
/** @var \Codeception\Module\Db */ | ||
private $databaseModule; | ||
|
||
/** @var \Codeception\Module\REST */ | ||
private $restModule; | ||
|
||
/** | ||
* Event hook before a test starts. | ||
* | ||
* @param \Codeception\TestInterface $test | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function _before(\Codeception\TestInterface $test) | ||
{ | ||
$this->databaseModule = $this->getModule('Db'); | ||
$this->restModule = $this->getModule('REST'); | ||
} | ||
|
||
/** | ||
* @param $url | ||
* @param array $params | ||
* @param array $files | ||
*/ | ||
public function sendPOSTAndVerifyResponseCodeIs200($url, $params = [], $files = []) | ||
{ | ||
$this->restModule->sendPOST($url, $params, $files); | ||
$this->restModule->seeResponseCodeIs(200); | ||
} | ||
|
||
/** | ||
* Set XDEBUG cookie for debugging rest connections | ||
*/ | ||
public function haveRESTXdebugCookie() | ||
{ | ||
$this->restModule->client->getCookieJar()->set(new Cookie('XDEBUG_SESSION', 'phpstorm')); | ||
} | ||
/** | ||
* @param $table | ||
* @param $criteria | ||
*/ | ||
public function deleteFromDatabase($table, $criteria = []) | ||
{ | ||
$this->databaseModule->_getDriver()->deleteQueryByCriteria($table, $criteria); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Codeception Test Suite Configuration | ||
# | ||
# Suite for acceptance tests. | ||
# Perform tests in browser using the WebDriver or PhpBrowser. | ||
# If you need both WebDriver and PHPBrowser tests - create a separate suite. | ||
|
||
actor: AcceptanceTester | ||
step_decorators: | ||
- \Codeception\Step\Retry | ||
- \Codeception\Step\TryTo | ||
modules: | ||
enabled: | ||
- PhpBrowser | ||
- Asserts | ||
- Db | ||
- REST | ||
- \Helper\Acceptance | ||
config: | ||
REST: | ||
depends: PhpBrowser | ||
url: '%URL%rest/' | ||
shortDebugResponse: 1000 # only the first 300 chars of the response | ||
PhpBrowser: | ||
url: '%URL%' | ||
timeout: 60 | ||
Db: | ||
dsn: 'mysql:host=%MYSQL_HOST%;dbname=%MYSQL_DB%;port=%MYSQL_PORT%' | ||
user: '%MYSQL_USER%' | ||
password: |
Oops, something went wrong.