Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move phpunit tests (#295) #313

Merged
merged 14 commits into from
Aug 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ script:
# 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
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
"symfony/console": "~2"
},
"autoload": {
"psr-4": {"Acquia\\Blt\\": "src/"}
"psr-4": {
"Acquia\\Blt\\": "src/",
"Acquia\\Blt\\Tests\\": "tests/phpunit/src/"
}
},
"bin": [
"bin/blt",
Expand Down
1 change: 1 addition & 0 deletions phing/tasks/tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<fileset dir="${repo.root}/tests/phpunit">
<include name="**/*Test*.php"/>
</fileset>
<fileset dir="${blt.root}/tests/phpunit/BltProject"/>
</batchtest>
</phpunit>
<phpunitreport infile="${reports.localDir}/phpunit/testsuites.xml" format="noframes" todir="${reports.localDir}/phpunit" />
Expand Down
4 changes: 2 additions & 2 deletions template/drush.wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 0 additions & 32 deletions template/tests/phpunit/src/TestBase.php

This file was deleted.

17 changes: 5 additions & 12 deletions tests/phpunit/BltTest.php → tests/phpunit/Blt/BltTest.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
<?php

namespace Drupal;
namespace Acquia\Blt\Tests\Blt;

use Symfony\Component\Yaml\Yaml;
use Acquia\Blt\Tests\BltTestBase;

/**
* Class BLTTest.
*
* Verifies that project structure and configuration matches BLT
* standards.
*/
class BltTest extends \PHPUnit_Framework_TestCase {

/**
* Class constructor.
*/
public function __construct() {
$this->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() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
<?php

namespace Drupal;
namespace Acquia\Blt\Tests\Blt;

use Symfony\Component\Yaml\Yaml;
use Acquia\Blt\Tests\BltTestBase;

/**
* Class DeployTest.
*
* Verifies that build artifact matches standards.
*/
class DeployTest extends \PHPUnit_Framework_TestCase {
class DeployTest extends BltTestBase {

/**
* Class constructor.
* {@inheritdoc}
*/
public function __construct() {

$this->projectDirectory = realpath(dirname(__FILE__) . '/../../');
$this->newProjectDir = dirname($this->projectDirectory) . '/blt-project';
$this->config = Yaml::parse(file_get_contents("{$this->newProjectDir}/project.yml"));
public function setUp() {
parent::setUp();
$this->deploy_dir = $this->newProjectDir . '/deploy';
}

/**
* Tests Phing deploy:build:all target.
*
* @group deploy
* @group blt
*/
public function testBltDeployBuild() {

Expand Down Expand Up @@ -63,6 +61,7 @@ public function testBltDeployBuild() {
*
* @group deploy
* @group deploy-push
* @group blt
*/
public function testBltDeployPush() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
<?php

namespace Drupal;
namespace Acquia\Blt\Tests\Blt;

use Symfony\Component\Yaml\Yaml;
use Acquia\Blt\Tests\BltTestBase;

/**
* Class DrupalVM.
*
* Verifies that Drupal VM integration works as expected.
*/
class DrupalVmTest extends \PHPUnit_Framework_TestCase {

/**
* Class constructor.
*/
public function __construct() {
$this->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');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<?php

namespace Drupal\Tests\PHPUnit;
namespace Acquia\Blt\Tests\BltProject;

use Acquia\Blt\Tests\BltProjectTestBase;

/**
* Class BehatTest.
*
* Verifies that behat configuration is as expected.
*/
class BehatTest extends TestBase {
class BehatTest extends BltProjectTestBase {

/**
* Tests Phing setup:behat target.
*
* @group blt-project
*/
public function testSetupBehat() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?php

namespace Drupal\Tests\PHPUnit;
namespace Acquia\Blt\Tests\BltProject;

use Acquia\Blt\Tests\BltProjectTestBase;

/**
* Class BuildTest.
*
* Verifies that build tasks work as expected.
*/
class BuildTest extends TestBase {
class BuildTest extends BltProjectTestBase {

/**
* Tests Phing setup:make target.
*
* This should build /make.yml.
*
* @group blt-project
*/
public function testSetupMake() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
<?php

namespace Drupal\Tests\PHPUnit;
namespace Acquia\Blt\Tests\BltProject;

use Acquia\Blt\Tests\BltProjectTestBase;

/**
* Class DrushTest.
*
* Verifies that git related tasks work as expected.
*/
class DrushTest extends TestBase {
class DrushTest extends BltProjectTestBase {

/**
* Tests that correct drush configuration is loaded.
*
* @group blt-project
*/
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(
Expand All @@ -29,9 +35,10 @@ 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));
$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', $drush_output['drush-conf']);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<?php

namespace Drupal\Tests\PHPUnit;
namespace Acquia\Blt\Tests\BltProject;

use Acquia\Blt\Tests\BltProjectTestBase;

/**
* Class GitTasksTest.
*
* Verifies that git related tasks work as expected.
*/
class GitTasksTest extends TestBase {
class GitTasksTest extends BltProjectTestBase {

/**
* Tests Phing setup:git-hooks target.
*
* @group blt-project
*/
public function testGitConfig() {
$this->assertFileExists($this->projectDirectory . '/.git');
Expand All @@ -29,6 +33,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);
Expand All @@ -38,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.'),
Expand All @@ -57,6 +63,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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php

namespace Drupal\Tests\PHPUnit;
namespace Acquia\Blt\Tests\BltProject;

use Acquia\Blt\Tests\BltProjectTestBase;

/**
* Class SettingsTest.
*
* Verifies $settings.php configuration.
*/
class SettingsTest extends TestBase {
class SettingsTest extends BltProjectTestBase {

/**
* Sets up require parameters for tests to run.
Expand All @@ -29,6 +31,8 @@ public function setupParams($env) {

/**
* Test configuration for production environment on ACE.
*
* @group blt-project
*/
public function testProd() {

Expand All @@ -40,6 +44,8 @@ public function testProd() {

/**
* Tests Phing setup:drupal:settings target.
*
* @group blt-project
*/
public function testSetupLocalSettings() {

Expand Down
Loading