From 392362e73e314bc54f1e8d77242359ed38dc5355 Mon Sep 17 00:00:00 2001 From: laszlovl Date: Fri, 1 May 2015 11:30:24 -0400 Subject: [PATCH] Add tests --- .travis.yml | 40 +++++++++++++++++++++++++++++++++ composer.json | 3 +++ phpunit.xml.dist | 13 +++++++++++ tests/ActiveRecordTest.php | 12 ++++++++++ tests/bootstrap.php | 15 +++++++++++++ tests/data/.gitignore | 1 + tests/data/config.php | 16 +++++++++++++ tests/override/ActiveRecord.php | 20 +++++++++++++++++ 8 files changed, 120 insertions(+) create mode 100644 .travis.yml create mode 100644 phpunit.xml.dist create mode 100644 tests/ActiveRecordTest.php create mode 100644 tests/bootstrap.php create mode 100644 tests/data/.gitignore create mode 100644 tests/data/config.php create mode 100644 tests/override/ActiveRecord.php diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d265e92 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,40 @@ +language: php + +php: + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - hhvm + - hhvm-nightly + +# run build against hhvm but allow them to fail +# http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail +matrix: + fast_finish: true + allow_failures: + - php: hhvm + - php: hhvm-nightly + - php: 7.0 + +# faster builds on new travis setup not using sudo +sudo: false + +# cache vendor dirs +cache: + directories: + - vendor + - $HOME/.composer/cache + +install: + - travis_retry composer self-update && composer --version + - travis_retry composer global require "fxp/composer-asset-plugin:1.0.0" + - export PATH="$HOME/.composer/vendor/bin:$PATH" + - travis_retry composer install --prefer-dist --no-interaction + +before_script: + - mysql -e 'CREATE DATABASE yiitest;'; + +script: + - phpunit --verbose $PHPUNIT_FLAGS + diff --git a/composer.json b/composer.json index d7e2a2b..54096a2 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,9 @@ "require": { "yiisoft/yii2": "~2.0" }, + "require-dev": { + "yiisoft/yii2-dev": "~2.0" + }, "autoload": { "psr-4": { "lvl\\staticactiverecord\\": "" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..ff34c5f --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,13 @@ + + + + + ./tests + + + diff --git a/tests/ActiveRecordTest.php b/tests/ActiveRecordTest.php new file mode 100644 index 0000000..3bf2a93 --- /dev/null +++ b/tests/ActiveRecordTest.php @@ -0,0 +1,12 @@ + [ + 'mysql' => [ + 'dsn' => 'mysql:host=127.0.0.1;dbname=yiitest', + 'username' => 'travis', + 'password' => '', + 'fixture' => __DIR__ . '/../../vendor/yiisoft/yii2-dev/tests/unit/data/mysql.sql', + ] + ], +]; + +if (is_file(__DIR__ . '/config.local.php')) { + include(__DIR__ . '/config.local.php'); +} +return $config; diff --git a/tests/override/ActiveRecord.php b/tests/override/ActiveRecord.php new file mode 100644 index 0000000..3570929 --- /dev/null +++ b/tests/override/ActiveRecord.php @@ -0,0 +1,20 @@ +