diff --git a/.travis.yml b/.travis.yml index e2e865967..97e8bb977 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,6 +49,7 @@ script: - source ${BLT_DIR}/scripts/travis/run_tests - source ${BLT_DIR}/scripts/blt/ci/internal/doctor.sh - phpunit ${BLT_DIR}/tests/phpunit --group blt-project -c ${BLT_DIR}/tests/phpunit/phpunit.xml + - phpunit ${BLT_DIR}/tests/phpunit --group blt-multisite -c ${BLT_DIR}/tests/phpunit/phpunit.xml # Deploy build artifact. - blt deploy:build - source ${BLT_DIR}/scripts/blt/ci/internal/test_artifact.sh diff --git a/phing/build.yml b/phing/build.yml index 965e22c3e..47baf3450 100644 --- a/phing/build.yml +++ b/phing/build.yml @@ -85,11 +85,13 @@ git: pre-commit: ${blt.root}/scripts/git-hooks commit-msg: ${blt.root}/scripts/git-hooks -multisite: - # The docroot/sites/default directory is used by default. - name: - - default - # - another_site +# You may provide a list of sites for BLT to run commands against, +# otherwise BLT will generate this sites list based on directories +# in ${docroot}/sites/*/ +# +# multisite: +# name: +# - default reports: localDir: ${repo.root}/reports diff --git a/phing/tasks/properties.xml b/phing/tasks/properties.xml index 66f323ac1..718fd48b3 100644 --- a/phing/tasks/properties.xml +++ b/phing/tasks/properties.xml @@ -56,6 +56,18 @@ + + + + + + + + + + + diff --git a/tests/phpunit/BltProject/PropertiesTest.php b/tests/phpunit/BltProject/PropertiesTest.php new file mode 100644 index 000000000..85905cdda --- /dev/null +++ b/tests/phpunit/BltProject/PropertiesTest.php @@ -0,0 +1,65 @@ +assertPropertyEquals('multisite.name', BLT_MULTISITE_NAME); + } + + /** + * Asserts that a given property has an expected value. + * + * @param string $property + * The property to check. + * @param string $expected + * The expected value of $property. + * @param string $site + * An optional site name. + */ + protected function assertPropertyEquals($property, $expected, $site = '') { + $value = $this->getProperty($property, $site); + $this->assertEquals($expected, $value, + "Expected value at $property to equal '$expected'. Instead, $property equals '$value'."); + } + + /** + * Gets the value a given property (optionally specifying a site). + * + * @param string $property + * The property to check. + * @param string $site + * An optional site name. + * + * @return string + * The value of $property. + */ + private function getProperty($property, $site = '') { + $output = []; + $blt_bin = $this->projectDirectory . '/vendor/bin/blt'; + exec( + // Run the echo-property task (optionally providing a site name) + // and parse its output. + "$blt_bin echo-property -Dproperty.name=$property " . (!empty($site) ? "-Dmultisite.name=$site" : "") . + // Run command with minimal output and console styling. + " -emacs -silent", $output + ); + // Property value will be output to the 1st line. + // Return an empty string if $property does not exist. + return !empty($output[0]) ? $output[0] : ''; + } + +} diff --git a/tests/phpunit/phpunit.xml b/tests/phpunit/phpunit.xml index 40aecaaad..9454138c4 100644 --- a/tests/phpunit/phpunit.xml +++ b/tests/phpunit/phpunit.xml @@ -5,6 +5,7 @@ +