Skip to content

Commit

Permalink
FIX Module can run as root project, i.e. as global composer install
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Jan 11, 2018
1 parent 52a0388 commit 0b42aaa
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ php:

before_install:
- composer self-update
- composer require silverstripe/framework ^4.0
- composer require silverstripe/recipe-cms ^1

script:
- php vendor/bin/phpunit --coverage-clover=coverage.xml
Expand Down
12 changes: 11 additions & 1 deletion bin/ssconsole
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@
*/

define('CONSOLE_BASE_DIR', realpath(__DIR__ . '/..'));
require CONSOLE_BASE_DIR . '/../../autoload.php';

foreach ([
// Root project installation, i.e. Travis or global composer
realpath(CONSOLE_BASE_DIR . '/vendor/autoload.php'),
// Installed as a vendor module in a project
realpath(CONSOLE_BASE_DIR . '/../../autoload.php'),
] as $vendorPath) {
if (file_exists($vendorPath)) {
require_once($vendorPath);
}
}

$scaffold = new \SilverLeague\Console\Framework\Scaffold;
$scaffold->run();
13 changes: 0 additions & 13 deletions tests/Command/Config/DumpCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,6 @@ public function testFilterOnAnyColumn()
$this->assertContains('%$Monolog\\\\Handler\\\\HandlerInterface', $result);
}

/**
* Ensure that numeric property keys are replaced with nada
*
* @covers ::getParsedOutput
*/
public function testNumericKeysAreNotShown()
{
Config::modify()->set('FooBar', 'my_property', [1 => 'baz', 'bar' => 'banter']);
$result = $this->executeTest(['--filter' => 'FooBar'])->getDisplay();
$this->assertNotContains('1', $result);
$this->assertContains('bar', $result);
}

/**
* Ensure that a ConfigCollectionInterface is returned
*
Expand Down
22 changes: 19 additions & 3 deletions tests/Command/Object/DebugCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,28 @@ class DebugCommandTest extends AbstractCommandTest
protected $member;

/**
* Get a member to test with
* Create a Member to play with
*/
public function setUp()
protected function setUp()
{
parent::setUp();
$this->member = Member::get()->first();

$member = Member::create();
$member->Email = 'unittest@example.com';
$member->Password = 'NotRelevant1';
$member->write();

$this->member = $member;
}

/**
* Delete fixtured members after tests have run
*/
protected function tearDown()
{
parent::tearDown();

$this->member->delete();
}

/**
Expand Down
7 changes: 6 additions & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

define('CONSOLE_BASE_DIR', realpath(__DIR__ . '/..'));

foreach([CONSOLE_BASE_DIR, realpath(CONSOLE_BASE_DIR . '/../..')] as $vendorPath) {
foreach([
// Root project, i.e. in Travis builds or globally installed
realpath(CONSOLE_BASE_DIR . '/vendor'),
// As a vendor module, i.e. in a project
realpath(CONSOLE_BASE_DIR . '/../..'
)] as $vendorPath) {
if (file_exists($vendorPath . '/autoload.php')) {
require_once $vendorPath . '/autoload.php';
require_once $vendorPath . '/silverstripe/framework/tests/bootstrap.php';
Expand Down

0 comments on commit 0b42aaa

Please sign in to comment.