From 49a07e17792bdade3d986e14c31f0d009d701d94 Mon Sep 17 00:00:00 2001 From: Stephanie Bridges Date: Tue, 16 Aug 2016 11:15:32 -0400 Subject: [PATCH 01/14] Moved tests in /template/tests/phpunit to /tests/phpunit. --- {template/tests/phpunit/Bolt => tests/phpunit/src}/BehatTest.php | 0 {template/tests/phpunit/Bolt => tests/phpunit/src}/BuildTest.php | 0 {template/tests/phpunit/Bolt => tests/phpunit/src}/DrushTest.php | 0 {template/tests/phpunit/Bolt => tests/phpunit/src}/GitTest.php | 0 .../tests/phpunit/Bolt => tests/phpunit/src}/SettingsTest.php | 0 {template/tests => tests}/phpunit/src/TestBase.php | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename {template/tests/phpunit/Bolt => tests/phpunit/src}/BehatTest.php (100%) rename {template/tests/phpunit/Bolt => tests/phpunit/src}/BuildTest.php (100%) rename {template/tests/phpunit/Bolt => tests/phpunit/src}/DrushTest.php (100%) rename {template/tests/phpunit/Bolt => tests/phpunit/src}/GitTest.php (100%) rename {template/tests/phpunit/Bolt => tests/phpunit/src}/SettingsTest.php (100%) rename {template/tests => tests}/phpunit/src/TestBase.php (100%) diff --git a/template/tests/phpunit/Bolt/BehatTest.php b/tests/phpunit/src/BehatTest.php similarity index 100% rename from template/tests/phpunit/Bolt/BehatTest.php rename to tests/phpunit/src/BehatTest.php diff --git a/template/tests/phpunit/Bolt/BuildTest.php b/tests/phpunit/src/BuildTest.php similarity index 100% rename from template/tests/phpunit/Bolt/BuildTest.php rename to tests/phpunit/src/BuildTest.php diff --git a/template/tests/phpunit/Bolt/DrushTest.php b/tests/phpunit/src/DrushTest.php similarity index 100% rename from template/tests/phpunit/Bolt/DrushTest.php rename to tests/phpunit/src/DrushTest.php diff --git a/template/tests/phpunit/Bolt/GitTest.php b/tests/phpunit/src/GitTest.php similarity index 100% rename from template/tests/phpunit/Bolt/GitTest.php rename to tests/phpunit/src/GitTest.php diff --git a/template/tests/phpunit/Bolt/SettingsTest.php b/tests/phpunit/src/SettingsTest.php similarity index 100% rename from template/tests/phpunit/Bolt/SettingsTest.php rename to tests/phpunit/src/SettingsTest.php diff --git a/template/tests/phpunit/src/TestBase.php b/tests/phpunit/src/TestBase.php similarity index 100% rename from template/tests/phpunit/src/TestBase.php rename to tests/phpunit/src/TestBase.php From 0c6f5b460d58c9aee9d2ac7ddcc74ab15a4ed199 Mon Sep 17 00:00:00 2001 From: Stephanie Bridges Date: Tue, 16 Aug 2016 12:36:52 -0400 Subject: [PATCH 02/14] Add autoload path for PHPUnit tests. --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index e2303829e..931869d71 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,11 @@ "autoload": { "psr-4": {"Acquia\\Blt\\": "src/"} }, + "autoload-dev": { + "psr-4": { + "Drupal\\Tests\\PHPUnit\\": "tests/phpunit/src/" + } + }, "bin": [ "bin/blt", "bin/blt-console" From 2967231b41457eebddae7107b3018394cb14c5b2 Mon Sep 17 00:00:00 2001 From: Stephanie Bridges Date: Tue, 16 Aug 2016 12:42:51 -0400 Subject: [PATCH 03/14] Move PSR-4 definition to correct autoload.. --- composer.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 931869d71..2163f5bde 100644 --- a/composer.json +++ b/composer.json @@ -13,10 +13,8 @@ "symfony/console": "~2" }, "autoload": { - "psr-4": {"Acquia\\Blt\\": "src/"} - }, - "autoload-dev": { "psr-4": { + "Acquia\\Blt\\": "src/", "Drupal\\Tests\\PHPUnit\\": "tests/phpunit/src/" } }, From 8bbb3271b260aa0e1bb2e75bc49b30800ac5d586 Mon Sep 17 00:00:00 2001 From: Stephanie Bridges Date: Wed, 17 Aug 2016 12:01:46 -0400 Subject: [PATCH 04/14] Set correct project directory. --- tests/phpunit/src/TestBase.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/src/TestBase.php b/tests/phpunit/src/TestBase.php index a0da3cabe..6634ecc29 100644 --- a/tests/phpunit/src/TestBase.php +++ b/tests/phpunit/src/TestBase.php @@ -21,7 +21,8 @@ abstract class TestBase extends \PHPUnit_Framework_TestCase { public function __construct($name = NULL, array $data = array(), $data_name = '') { parent::__construct($name, $data, $data_name); - $this->projectDirectory = dirname(dirname(dirname(__DIR__))); + $directory = realpath(dirname(__FILE__) . '/../../../'); + $this->projectDirectory = dirname($directory) . '/blt-project'; $this->drupalRoot = $this->projectDirectory . '/docroot'; $this->config = Yaml::parse(file_get_contents("{$this->projectDirectory}/project.yml")); if (file_exists("{$this->projectDirectory}/project.local.yml")) { From 1a71a85e6f3b46500cb4e12a2b41c4b93fd44f49 Mon Sep 17 00:00:00 2001 From: Stephanie Bridges Date: Wed, 17 Aug 2016 16:50:01 -0400 Subject: [PATCH 05/14] Add path to drushrc.php to drush.launcher option (#295) --- template/drush.wrapper | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/drush.wrapper b/template/drush.wrapper index 113b38334..727d29c17 100755 --- a/template/drush.wrapper +++ b/template/drush.wrapper @@ -45,7 +45,7 @@ fi DOCROOT=$(${DIR}/vendor/bin/blt echo-property -Dproperty.name=drush.root -S -e) if [ -z "$DOCROOT" ]; then - vendor/bin/drush.launcher --alias-path=${DIR}/drush/site-aliases "$@" + vendor/bin/drush.launcher --config=${DIR}/drush/drushrc.php --alias-path=${DIR}/drush/site-aliases "$@" else - vendor/bin/drush.launcher --alias-path=${DIR}/drush/site-aliases "$@" -r $DOCROOT + vendor/bin/drush.launcher --config=${DIR}/drush/drushrc.php --alias-path=${DIR}/drush/site-aliases "$@" -r $DOCROOT fi From d2c7c0a932be8179c5a18b884f207dad0026f53c Mon Sep 17 00:00:00 2001 From: Stephanie Bridges Date: Wed, 17 Aug 2016 17:26:51 -0400 Subject: [PATCH 06/14] Change PHPUnit test to look for correct config file in output. (#295) --- tests/phpunit/src/DrushTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/src/DrushTest.php b/tests/phpunit/src/DrushTest.php index ff1d6b86f..dd89f2e31 100644 --- a/tests/phpunit/src/DrushTest.php +++ b/tests/phpunit/src/DrushTest.php @@ -11,6 +11,8 @@ class DrushTest extends TestBase { /** * Tests that correct drush configuration is loaded. + * + * @group drush */ public function testDrushConfig() { @@ -29,9 +31,8 @@ public function testDrushConfig() { foreach ($dirs as $dir) { chdir($dir); print "Executing \"$command\" in $dir \n"; - // If it contains the local URI, we know it is correctly loading - // drushrc.php. - $this->assertContains($this->config['project']['local']['hostname'], shell_exec($command)); + // Check for the path to drushrc.php that is included in the project. + $this->assertContains($this->projectDirectory . '/drush/drushrc.php', shell_exec($command)); } } From e44370dc4318dd55edc150ce30b0ea3bb3877cf6 Mon Sep 17 00:00:00 2001 From: Stephanie Bridges Date: Wed, 17 Aug 2016 17:50:13 -0400 Subject: [PATCH 07/14] Use --format=json on drush command for output. --- tests/phpunit/src/DrushTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/src/DrushTest.php b/tests/phpunit/src/DrushTest.php index dd89f2e31..7a997f069 100644 --- a/tests/phpunit/src/DrushTest.php +++ b/tests/phpunit/src/DrushTest.php @@ -19,7 +19,9 @@ public function testDrushConfig() { // We must define the absolute path of the binary because child shell // processes in PHP to not inherit $PATH setting from environment. $drush_bin = $this->projectDirectory . '/vendor/bin/drush'; - $command = "$drush_bin status"; + // Use --format=json output so we don't have to deal with output line + // wrapping when running the tests. + $command = "$drush_bin status --format=json"; // Test that drush can be run from the following directories. $dirs = array( @@ -31,8 +33,10 @@ public function testDrushConfig() { foreach ($dirs as $dir) { chdir($dir); print "Executing \"$command\" in $dir \n"; + $json_output = shell_exec($command); + $drush_output = json_decode($json_output, TRUE); // Check for the path to drushrc.php that is included in the project. - $this->assertContains($this->projectDirectory . '/drush/drushrc.php', shell_exec($command)); + $this->assertContains($this->projectDirectory . '/drush/drushrc.php', $drush_output['drush-conf']); } } From 0be7d6a0a609331fec7f25b24c848ff5a02b2e75 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Thu, 18 Aug 2016 10:36:57 -0400 Subject: [PATCH 08/14] Separating blt-project tests from blt tests. --- composer.json | 2 +- phing/tasks/tests.xml | 1 + tests/phpunit/{ => Blt}/BltTest.php | 17 ++++------- tests/phpunit/{ => Blt}/DeployTest.php | 14 ++++----- tests/phpunit/{ => Blt}/DrupalVmTest.php | 16 ++++------ .../phpunit/{src => BltProject}/BehatTest.php | 5 ++-- .../phpunit/{src => BltProject}/BuildTest.php | 4 ++- .../phpunit/{src => BltProject}/DrushTest.php | 4 +-- tests/phpunit/{src => BltProject}/GitTest.php | 8 ++++- .../{src => BltProject}/SettingsTest.php | 6 +++- .../{TestBase.php => BltProjectTestBase.php} | 13 ++++----- tests/phpunit/src/BltTestBase.php | 29 +++++++++++++++++++ 12 files changed, 74 insertions(+), 45 deletions(-) rename tests/phpunit/{ => Blt}/BltTest.php (67%) rename tests/phpunit/{ => Blt}/DeployTest.php (87%) rename tests/phpunit/{ => Blt}/DrupalVmTest.php (68%) rename tests/phpunit/{src => BltProject}/BehatTest.php (79%) rename tests/phpunit/{src => BltProject}/BuildTest.php (86%) rename tests/phpunit/{src => BltProject}/DrushTest.php (94%) rename tests/phpunit/{src => BltProject}/GitTest.php (96%) rename tests/phpunit/{src => BltProject}/SettingsTest.php (91%) rename tests/phpunit/src/{TestBase.php => BltProjectTestBase.php} (69%) create mode 100644 tests/phpunit/src/BltTestBase.php diff --git a/composer.json b/composer.json index 2163f5bde..644d96d8f 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "autoload": { "psr-4": { "Acquia\\Blt\\": "src/", - "Drupal\\Tests\\PHPUnit\\": "tests/phpunit/src/" + "Acquia\\Blt\\Tests\\": "tests/phpunit/src/" } }, "bin": [ diff --git a/phing/tasks/tests.xml b/phing/tasks/tests.xml index 01131321e..c05f44b18 100644 --- a/phing/tasks/tests.xml +++ b/phing/tasks/tests.xml @@ -88,6 +88,7 @@ + diff --git a/tests/phpunit/BltTest.php b/tests/phpunit/Blt/BltTest.php similarity index 67% rename from tests/phpunit/BltTest.php rename to tests/phpunit/Blt/BltTest.php index a74e753da..acf7e7d8b 100644 --- a/tests/phpunit/BltTest.php +++ b/tests/phpunit/Blt/BltTest.php @@ -1,8 +1,8 @@ projectDirectory = realpath(dirname(__FILE__) . '/../../'); - $this->newProjectDir = dirname($this->projectDirectory) . '/blt-project'; - $this->config = Yaml::parse(file_get_contents("{$this->newProjectDir}/project.yml")); - } +class BltTest extends BltTestBase { /** * Tests Phing pt:create target. + * + * @group blt */ public function testBltCreate() { diff --git a/tests/phpunit/DeployTest.php b/tests/phpunit/Blt/DeployTest.php similarity index 87% rename from tests/phpunit/DeployTest.php rename to tests/phpunit/Blt/DeployTest.php index d0bd801d3..b46843efd 100644 --- a/tests/phpunit/DeployTest.php +++ b/tests/phpunit/Blt/DeployTest.php @@ -1,24 +1,22 @@ projectDirectory = realpath(dirname(__FILE__) . '/../../'); - $this->newProjectDir = dirname($this->projectDirectory) . '/blt-project'; - $this->config = Yaml::parse(file_get_contents("{$this->newProjectDir}/project.yml")); $this->deploy_dir = $this->newProjectDir . '/deploy'; } @@ -26,6 +24,7 @@ public function __construct() { * Tests Phing deploy:build:all target. * * @group deploy + * @group blt */ public function testBltDeployBuild() { @@ -63,6 +62,7 @@ public function testBltDeployBuild() { * * @group deploy * @group deploy-push + * @group blt */ public function testBltDeployPush() { diff --git a/tests/phpunit/DrupalVmTest.php b/tests/phpunit/Blt/DrupalVmTest.php similarity index 68% rename from tests/phpunit/DrupalVmTest.php rename to tests/phpunit/Blt/DrupalVmTest.php index fd3e40df4..6c625eeaa 100644 --- a/tests/phpunit/DrupalVmTest.php +++ b/tests/phpunit/Blt/DrupalVmTest.php @@ -1,7 +1,8 @@ projectDirectory = realpath(dirname(__FILE__) . '/../../'); - $this->newProjectDir = dirname($this->projectDirectory) . '/blt-project'; - $this->config = Yaml::parse(file_get_contents("{$this->newProjectDir}/project.yml")); - } +class DrupalVmTest extends BltTestBase { /** * Tests Phing vm:init target. + * + * @group blt */ public function testVmInit() { $this->assertFileExists($this->newProjectDir . '/Vagrantfile'); diff --git a/tests/phpunit/src/BehatTest.php b/tests/phpunit/BltProject/BehatTest.php similarity index 79% rename from tests/phpunit/src/BehatTest.php rename to tests/phpunit/BltProject/BehatTest.php index 488951cd7..d5068b5f4 100644 --- a/tests/phpunit/src/BehatTest.php +++ b/tests/phpunit/BltProject/BehatTest.php @@ -1,13 +1,14 @@ assertFileExists($this->projectDirectory . '/.git'); @@ -29,6 +31,8 @@ public function testGitConfig() { * The PHPUnit message to be output for this datapoint. * * @dataProvider providerTestGitHookCommitMsg + * + * @group blt-project */ public function testGitHookCommitMsg($is_valid, $commit_message, $message = NULL) { $this->assertCommitMessageValidity($is_valid, $commit_message, $message); @@ -57,6 +61,8 @@ public function providerTestGitHookCommitMsg() { * Tests operation of scripts/git-hooks/pre-commit. * * Should assert that code validation via phpcs is functioning. + * + * @group blt-project */ public function testGitPreCommitHook() { // Commits must be executed inside of new project directory. diff --git a/tests/phpunit/src/SettingsTest.php b/tests/phpunit/BltProject/SettingsTest.php similarity index 91% rename from tests/phpunit/src/SettingsTest.php rename to tests/phpunit/BltProject/SettingsTest.php index db8401335..22c9d577f 100644 --- a/tests/phpunit/src/SettingsTest.php +++ b/tests/phpunit/BltProject/SettingsTest.php @@ -7,7 +7,7 @@ * * Verifies $settings.php configuration. */ -class SettingsTest extends TestBase { +class SettingsTest extends BltProjectTestBase { /** * Sets up require parameters for tests to run. @@ -29,6 +29,8 @@ public function setupParams($env) { /** * Test configuration for production environment on ACE. + * + * @group blt-project */ public function testProd() { @@ -40,6 +42,8 @@ public function testProd() { /** * Tests Phing setup:drupal:settings target. + * + * @group blt-project */ public function testSetupLocalSettings() { diff --git a/tests/phpunit/src/TestBase.php b/tests/phpunit/src/BltProjectTestBase.php similarity index 69% rename from tests/phpunit/src/TestBase.php rename to tests/phpunit/src/BltProjectTestBase.php index 6634ecc29..352c203da 100644 --- a/tests/phpunit/src/TestBase.php +++ b/tests/phpunit/src/BltProjectTestBase.php @@ -1,15 +1,15 @@ projectDirectory = dirname($directory) . '/blt-project'; + + $this->projectDirectory = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__)))))); $this->drupalRoot = $this->projectDirectory . '/docroot'; $this->config = Yaml::parse(file_get_contents("{$this->projectDirectory}/project.yml")); if (file_exists("{$this->projectDirectory}/project.local.yml")) { diff --git a/tests/phpunit/src/BltTestBase.php b/tests/phpunit/src/BltTestBase.php new file mode 100644 index 000000000..dce6caeff --- /dev/null +++ b/tests/phpunit/src/BltTestBase.php @@ -0,0 +1,29 @@ +bltDirectory = realpath(dirname(__FILE__) . '/../../'); + $this->newProjectDir = dirname($this->bltDirectory) . '/blt-project'; + $this->config = Yaml::parse(file_get_contents("{$this->newProjectDir}/project.yml")); + } + +} From 02485a9cf32d1c0362141da5f0acfb3f63cb6a8f Mon Sep 17 00:00:00 2001 From: Stephanie Bridges Date: Thu, 18 Aug 2016 13:42:40 -0400 Subject: [PATCH 09/14] Fix directory name, move setup to setUp() method. --- tests/phpunit/src/BltProjectTestBase.php | 9 ++++----- tests/phpunit/src/BltTestBase.php | 10 +++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/src/BltProjectTestBase.php b/tests/phpunit/src/BltProjectTestBase.php index 352c203da..070853c69 100644 --- a/tests/phpunit/src/BltProjectTestBase.php +++ b/tests/phpunit/src/BltProjectTestBase.php @@ -16,12 +16,11 @@ abstract class BltProjectTestBase extends \PHPUnit_Framework_TestCase { protected $config; /** - * Class constructor. + * {@inheritdoc} */ - public function __construct($name = NULL, array $data = array(), $data_name = '') { - parent::__construct($name, $data, $data_name); - - $this->projectDirectory = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__)))))); + public function setUp() { + parent::setUp(); + $this->projectDirectory = $this->projectDirectory = dirname(dirname(dirname((__DIR__)))); $this->drupalRoot = $this->projectDirectory . '/docroot'; $this->config = Yaml::parse(file_get_contents("{$this->projectDirectory}/project.yml")); if (file_exists("{$this->projectDirectory}/project.local.yml")) { diff --git a/tests/phpunit/src/BltTestBase.php b/tests/phpunit/src/BltTestBase.php index dce6caeff..4806c2d67 100644 --- a/tests/phpunit/src/BltTestBase.php +++ b/tests/phpunit/src/BltTestBase.php @@ -16,14 +16,14 @@ abstract class BltTestBase extends \PHPUnit_Framework_TestCase { protected $config; /** - * Class constructor. + * {@inheritdoc} */ - public function __construct($name = NULL, array $data = array(), $data_name = '') { - parent::__construct($name, $data, $data_name); - + public function setUp() { + parent::setUp(); $this->bltDirectory = realpath(dirname(__FILE__) . '/../../'); - $this->newProjectDir = dirname($this->bltDirectory) . '/blt-project'; + $this->newProjectDir = dirname(dirname($this->bltDirectory)) . '/blt-project'; $this->config = Yaml::parse(file_get_contents("{$this->newProjectDir}/project.yml")); + } } From 8b589e67d8300c4ffc90602a77b42df17008c7cf Mon Sep 17 00:00:00 2001 From: Stephanie Bridges Date: Thu, 18 Aug 2016 13:43:46 -0400 Subject: [PATCH 10/14] Fix namespace, add group, move constructor to setUp(). --- tests/phpunit/Blt/DeployTest.php | 7 +++---- tests/phpunit/BltProject/BehatTest.php | 2 ++ tests/phpunit/BltProject/BuildTest.php | 3 ++- tests/phpunit/BltProject/DrushTest.php | 3 ++- tests/phpunit/BltProject/GitTest.php | 3 ++- tests/phpunit/BltProject/SettingsTest.php | 3 ++- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/Blt/DeployTest.php b/tests/phpunit/Blt/DeployTest.php index b46843efd..7a81da404 100644 --- a/tests/phpunit/Blt/DeployTest.php +++ b/tests/phpunit/Blt/DeployTest.php @@ -12,11 +12,10 @@ class DeployTest extends BltTestBase { /** - * Class constructor. + * {@inheritdoc} */ - public function __construct($name = NULL, array $data = array(), $data_name = '') { - parent::__construct($name, $data, $data_name); - + public function setUp() { + parent::setUp(); $this->deploy_dir = $this->newProjectDir . '/deploy'; } diff --git a/tests/phpunit/BltProject/BehatTest.php b/tests/phpunit/BltProject/BehatTest.php index d5068b5f4..7ffb4ceac 100644 --- a/tests/phpunit/BltProject/BehatTest.php +++ b/tests/phpunit/BltProject/BehatTest.php @@ -12,6 +12,8 @@ class BehatTest extends BltProjectTestBase { /** * Tests Phing setup:behat target. + * + * @group blt-project */ public function testSetupBehat() { diff --git a/tests/phpunit/BltProject/BuildTest.php b/tests/phpunit/BltProject/BuildTest.php index 15d5e4324..52533bed5 100644 --- a/tests/phpunit/BltProject/BuildTest.php +++ b/tests/phpunit/BltProject/BuildTest.php @@ -1,6 +1,7 @@ Date: Thu, 18 Aug 2016 13:44:32 -0400 Subject: [PATCH 11/14] Add separate phpunit test calls for travis run. --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7f1219dbf..3f9425efa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -84,10 +84,12 @@ script: - blt deploy:build # Add Drupal VM config to repo. - blt vm:init + # Run the 'blt-project' phpunit tests. + - phpunit vendor/acquia/blt/tests/phpunit --group blt-project # Switch back to 'blt' directory. - cd ../blt # Run 'blt' phpunit tests, excluding deploy-push tests. - - phpunit tests/phpunit --exclude-group deploy-push + - phpunit tests/phpunit --group blt --exclude-group deploy-push deploy: provider: script From ae80fdeaaddeb8b4e877828cf383935caec9a54a Mon Sep 17 00:00:00 2001 From: Stephanie Bridges Date: Thu, 18 Aug 2016 18:32:15 -0400 Subject: [PATCH 12/14] Code sniffer cleanup. --- tests/phpunit/Blt/DrupalVmTest.php | 1 - tests/phpunit/BltProject/BehatTest.php | 1 + tests/phpunit/BltProject/BuildTest.php | 1 + tests/phpunit/BltProject/DrushTest.php | 1 + tests/phpunit/BltProject/GitTest.php | 1 + tests/phpunit/BltProject/SettingsTest.php | 1 + 6 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/Blt/DrupalVmTest.php b/tests/phpunit/Blt/DrupalVmTest.php index 6c625eeaa..1b6cc9a39 100644 --- a/tests/phpunit/Blt/DrupalVmTest.php +++ b/tests/phpunit/Blt/DrupalVmTest.php @@ -3,7 +3,6 @@ namespace Acquia\Blt\Tests\Blt; use Acquia\Blt\Tests\BltTestBase; -use Symfony\Component\Yaml\Yaml; /** * Class DrupalVM. diff --git a/tests/phpunit/BltProject/BehatTest.php b/tests/phpunit/BltProject/BehatTest.php index 7ffb4ceac..52f2742af 100644 --- a/tests/phpunit/BltProject/BehatTest.php +++ b/tests/phpunit/BltProject/BehatTest.php @@ -1,6 +1,7 @@ Date: Thu, 18 Aug 2016 18:33:17 -0400 Subject: [PATCH 13/14] Fixes to allow the tests to be run in a symlinked directory from blt-project. --- tests/phpunit/BltProject/GitTest.php | 2 +- tests/phpunit/src/BltProjectTestBase.php | 26 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/BltProject/GitTest.php b/tests/phpunit/BltProject/GitTest.php index da0016539..d2dd281f8 100644 --- a/tests/phpunit/BltProject/GitTest.php +++ b/tests/phpunit/BltProject/GitTest.php @@ -44,7 +44,7 @@ public function testGitHookCommitMsg($is_valid, $commit_message, $message = NULL * Data provider. */ public function providerTestGitHookCommitMsg() { - $prefix = $this->config['project']['prefix']; + $prefix = isset($this->config['project']) ? $this->config['project']['prefix'] : ''; return array( array(FALSE, "This is a bad commit.", 'Missing prefix and ticket number.'), array(FALSE, "123: This is a bad commit.", 'Missing project prefix.'), diff --git a/tests/phpunit/src/BltProjectTestBase.php b/tests/phpunit/src/BltProjectTestBase.php index 070853c69..b652511c6 100644 --- a/tests/phpunit/src/BltProjectTestBase.php +++ b/tests/phpunit/src/BltProjectTestBase.php @@ -13,16 +13,30 @@ abstract class BltProjectTestBase extends \PHPUnit_Framework_TestCase { protected $projectDirectory; protected $drupalRoot; - protected $config; + protected $config = []; /** - * {@inheritdoc} + * BltProjectTestBase constructor. + * + * @inheritdoc */ - public function setUp() { - parent::setUp(); - $this->projectDirectory = $this->projectDirectory = dirname(dirname(dirname((__DIR__)))); + public function __construct($name = NULL, array $data = [], $dataName = '') { + parent::__construct($name, $data, $dataName); + + // This seems super hacky, but when blt is included as a symlink in the + // test project, php resolves the symlink and we end up in the wrong + // directory when Travis runs the tests. + if (strpos(__DIR__, 'vendor/acquia') !== FALSE) { + $this->projectDirectory = dirname(dirname(dirname(dirname(dirname(dirname((__DIR__))))))); + } + else { + $this->projectDirectory = getcwd(); + } + $this->drupalRoot = $this->projectDirectory . '/docroot'; - $this->config = Yaml::parse(file_get_contents("{$this->projectDirectory}/project.yml")); + if (file_exists("{$this->projectDirectory}/project.yml")) { + $this->config = Yaml::parse(file_get_contents("{$this->projectDirectory}/project.yml")); + } if (file_exists("{$this->projectDirectory}/project.local.yml")) { $this->config = array_replace_recursive($this->config, Yaml::parse(file_get_contents("{$this->projectDirectory}/project.local.yml"))); } From 967d30f4df095896a4d54a6fd659a4429d446d73 Mon Sep 17 00:00:00 2001 From: Stephanie Bridges Date: Fri, 19 Aug 2016 10:27:38 -0400 Subject: [PATCH 14/14] Remove redundant test call. --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f9425efa..b1ff6fc6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -84,8 +84,6 @@ script: - blt deploy:build # Add Drupal VM config to repo. - blt vm:init - # Run the 'blt-project' phpunit tests. - - phpunit vendor/acquia/blt/tests/phpunit --group blt-project # Switch back to 'blt' directory. - cd ../blt # Run 'blt' phpunit tests, excluding deploy-push tests.