diff --git a/.travis.yml b/.travis.yml index 0e349ef2..c244c3b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,4 @@ version: ~> 1.0 import: - - silverstripe/silverstripe-travis-shared:config/provision/standard-jobs-fixed.yml - -env: - global: - - COMPOSER_ROOT_VERSION="1.x-dev" - - REQUIRE_RECIPE="4.x-dev" - - PHPUNIT_TEST=1 + - silverstripe/silverstripe-travis-shared:config/provision/standard-jobs-range.yml diff --git a/build.php b/build.php deleted file mode 100644 index 8bd98ff5..00000000 --- a/build.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -$filename = 'silverstripe_extension.phar'; - -if (file_exists($filename)) { - unlink($filename); -} - -$phar = new \Phar($filename, 0, 'extension.phar'); -$phar->setSignatureAlgorithm(\Phar::SHA1); -$phar->startBuffering(); - -foreach (findFiles('src') as $path) { - $phar->addFromString($path, file_get_contents(__DIR__ . '/' . $path)); -} - -$phar->addFromString('init.php', file_get_contents(__DIR__ . '/init.php')); - -$phar->setStub(<< - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -Phar::mapPhar('extension.phar'); - -return require 'phar://extension.phar/init.php'; - -__HALT_COMPILER(); -STUB -); -$phar->stopBuffering(); - -function findFiles($dir) -{ - $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST); - - $files = array(); - foreach ($iterator as $path) { - if ($path->isFile()) { - $files[] = $path->getPath() . DIRECTORY_SEPARATOR . $path->getFilename(); - } - } - - return $files; -} diff --git a/composer.json b/composer.json index 97cb3525..e358e68d 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "require": { "php": ">=5.6", "sminnee/phpunit": "^5.7", + "squizlabs/php_codesniffer": "^3", "behat/behat": "^3.2", "behat/mink": "^1.7", "behat/mink-extension": "^2.1", @@ -34,11 +35,7 @@ }, "autoload": { "psr-4": { - "SilverStripe\\BehatExtension\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { + "SilverStripe\\BehatExtension\\": "src/", "SilverStripe\\BehatExtension\\Tests\\": "tests/php/" } }, diff --git a/init.php b/init.php deleted file mode 100644 index f3021e5f..00000000 --- a/init.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -spl_autoload_register(function ($class) { - if (false !== strpos($class, 'SilverStripe\\BehatExtension')) { - require_once(__DIR__ . '/src/' . str_replace('\\', '/', $class) . '.php'); - return true; - } -}, true, false); - -return new SilverStripe\BehatExtension\Extension; diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 00000000..ddbffb00 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,17 @@ + + + CodeSniffer ruleset for SilverStripe coding conventions. + + src + tests + + + + + + + + + + + diff --git a/src/Context/SilverStripeContext.php b/src/Context/SilverStripeContext.php index b8c0ab68..54f87987 100644 --- a/src/Context/SilverStripeContext.php +++ b/src/Context/SilverStripeContext.php @@ -87,7 +87,7 @@ abstract class SilverStripeContext extends MinkContext implements SilverStripeAw */ public function __construct(array $parameters = null) { - if (!preg_match('/\\\FeatureContext$/', get_class($this))) { + if (!preg_match('#[\\\]FeatureContext$#', get_class($this))) { throw new InvalidArgumentException( 'Subclasses of SilverStripeContext must be named FeatureContext. Found "' . get_class($this) . '""' ); diff --git a/tests/php/SilverStripeContextTest.php b/tests/php/SilverStripeContextTest.php index 9f3c96c1..e9b8c1a2 100644 --- a/tests/php/SilverStripeContextTest.php +++ b/tests/php/SilverStripeContextTest.php @@ -11,18 +11,11 @@ use SilverStripe\BehatExtension\Tests\SilverStripeContextTest\FeatureContext; use SilverStripe\Dev\SapphireTest; -class SilverStripeContextTest extends \PHPUnit_Framework_TestCase +class SilverStripeContextTest extends SapphireTest { protected $backupGlobals = false; - public static function setUpBeforeClass() - { - // Bootstrap test environment - parent::setUpBeforeClass(); - SapphireTest::start(); - } - /** * @expectedException \LogicException * @expectedExceptionMessage Cannot find 'region_map' in the behat.yml