From a58416b6f67b48651960368bbc513b92fed786f6 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 13 Apr 2017 13:52:16 +1200 Subject: [PATCH] New style travis tests - Removed PHP 5.5. build (no longer supported) - Removed PG and SQLite tests (tested through installer nightly) - Added code coverage and linting tests - Fixed linting errors --- .travis.yml | 32 +++++++++++++-------- _config/config.yml | 0 composer.json | 11 ++++++-- phpunit.xml.dist | 16 +++++++++++ tests/ReportTest.php | 5 ++-- tests/ReportTest_FakeObject.php | 39 ++++++++++++++++++++++++++ tests/ReportTest_FakeTest.php | 36 ++++++++++++++++++++++++ tests/ReportTest_FakeTest2.php | 35 +++++++++++++++++++++++ tests/ReportTest_FakeTest_Abstract.php | 37 ++++++++++++++++++++++++ 9 files changed, 194 insertions(+), 17 deletions(-) create mode 100644 _config/config.yml create mode 100644 phpunit.xml.dist create mode 100644 tests/ReportTest_FakeObject.php create mode 100644 tests/ReportTest_FakeTest.php create mode 100644 tests/ReportTest_FakeTest2.php create mode 100644 tests/ReportTest_FakeTest_Abstract.php diff --git a/.travis.yml b/.travis.yml index 060bbb02..2521990d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,40 @@ -# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details +language: php sudo: false -language: php +env: + global: + - COMPOSER_ROOT_VERSION=1.0.x-dev env: global: - CORE_RELEASE=master matrix: + fast_finish: true include: - php: 5.6 - env: DB=MYSQL PHPCS_TEST=1 + env: DB=MYSQL PHPUNIT_TEST=1 PHPCS_TEST=1 - php: 7.0 - env: DB=PGSQL + env: DB=MYSQL PHPUNIT_TEST=1 - php: 7.1.2 - env: DB=MYSQL + env: DB=MYSQL PDO=1 PHPUNIT_COVERAGE_TEST=1 before_script: - composer validate - composer self-update || true - - git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support - - php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss - - cd ~/builds/ss - - composer install + - "if [ \"$PHPCS_TEST\" = \"1\" ]; then pyrus install pear/PHP_CodeSniffer; fi" + - phpenv rehash + - phpenv config-rm xdebug.ini + - composer validate + - composer install --prefer-dist + - composer require --no-update --prefer-dist silverstripe/admin:1.0.x-dev silverstripe/framework:4.0.x-dev silverstripe/versioned:1.0.x-dev silverstripe/config:1.0.x-dev silverstripe/assets:1.0.x-dev --prefer-dist + - composer update script: - - vendor/bin/phpunit reports/tests - - if [[ $PHPCS_TEST ]]; then (cd reports && composer run-script lint); fi + - "if [ \"$PHPUNIT_TEST\" = \"1\" ]; then vendor/bin/phpunit; fi" + - "if [ \"$PHPCS_TEST\" = \"1\" ]; then composer run-script lint; fi" + - "if [ \"$PHPUNIT_COVERAGE_TEST\" = \"1\" ]; then vendor/bin/phpunit --coverage-clover=coverage.xml; fi" + +after_success: + - "if [ \"$PHPUNIT_COVERAGE_TEST\" = \"1\" ]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi" diff --git a/_config/config.yml b/_config/config.yml new file mode 100644 index 00000000..e69de29b diff --git a/composer.json b/composer.json index 13e18394..19f6e02a 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,11 @@ } ], "require": { - "silverstripe/framework": "^4.0@dev", - "silverstripe/admin": "^1.0@dev" + "silverstripe/framework": "4.0.x-dev", + "silverstripe/admin": "1.0.x-dev", + "silverstripe/versioned": "1.0.x-dev", + "silverstripe/config": "1.0.x-dev", + "silverstripe/assets": "1.0.x-dev" }, "require-dev": { "phpunit/phpunit": "^5.7" @@ -36,5 +39,7 @@ "scripts": { "lint": "phpcs code/ tests/", "lint-clean": "phpcbf code/ tests/" - } + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 00000000..a07c0ae4 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,16 @@ + + + + tests + + + + + . + + tests/ + + + + + diff --git a/tests/ReportTest.php b/tests/ReportTest.php index b6ac5fc3..a98e82f2 100644 --- a/tests/ReportTest.php +++ b/tests/ReportTest.php @@ -2,10 +2,9 @@ namespace SilverStripe\Reports\Tests; -use SilverStripe\Dev\SapphireTest; -use SilverStripe\Forms\GridField\GridField; -use SilverStripe\Forms\GridField\GridFieldDataColumns; use SilverStripe\Reports\Report; +use SilverStripe\Dev\SapphireTest; +use SilverStripe\Forms\GridField\GridFieldDataColumns; use SilverStripe\Reports\Tests\ReportTest\FakeObject; use SilverStripe\Reports\Tests\ReportTest\FakeTest; use SilverStripe\Reports\Tests\ReportTest\FakeTest2; diff --git a/tests/ReportTest_FakeObject.php b/tests/ReportTest_FakeObject.php new file mode 100644 index 00000000..93b134df --- /dev/null +++ b/tests/ReportTest_FakeObject.php @@ -0,0 +1,39 @@ + 'Varchar' + ); + + /** + * @return String Absolute URL to the end-user view for this record. + * Example: http://mysite.com/my-record + */ + public function Link() + { + return Controller::join_links('dummy-link', $this->ID); + } + + public function CMSEditLink() + { + return Controller::join_links('dummy-edit-link', $this->ID); + } + + public function PreviewLink($action = null) + { + return false; + } + + public function getMimeType() + { + return 'text/html'; + } +} diff --git a/tests/ReportTest_FakeTest.php b/tests/ReportTest_FakeTest.php new file mode 100644 index 00000000..2739053b --- /dev/null +++ b/tests/ReportTest_FakeTest.php @@ -0,0 +1,36 @@ + array( + "title" => "Page Title", + "link" => true, + ) + ); + } + public function sourceRecords($params, $sort, $limit) + { + return new ArrayList(); + } + + public function sort() + { + return 100; + } +} diff --git a/tests/ReportTest_FakeTest2.php b/tests/ReportTest_FakeTest2.php new file mode 100644 index 00000000..4c38b962 --- /dev/null +++ b/tests/ReportTest_FakeTest2.php @@ -0,0 +1,35 @@ + array( + "title" => "Page Title 2" + ) + ); + } + public function sourceRecords($params, $sort, $limit) + { + return new ArrayList(); + } + + public function sort() + { + return 98; + } +} diff --git a/tests/ReportTest_FakeTest_Abstract.php b/tests/ReportTest_FakeTest_Abstract.php new file mode 100644 index 00000000..4e144efe --- /dev/null +++ b/tests/ReportTest_FakeTest_Abstract.php @@ -0,0 +1,37 @@ + array( + "title" => "Page Title Abstract" + ) + ); + } + public function sourceRecords($params, $sort, $limit) + { + return new ArrayList(); + } + + public function sort() + { + return 5; + } +}