diff --git a/.git.template b/.git.template new file mode 100644 index 0000000..7249b2d --- /dev/null +++ b/.git.template @@ -0,0 +1,32 @@ +# If applied, this commit will ... + +# Why was this change necessary? Improvements brought about by the +# change. + +# End + +# Format +# -------------------- +# (If applied, this commit will...) (Max 72 char) +# |<---- Preferably using up to 50 chars --->|<------------------->| +# Example: +# Implement automated commit messages + +# (Optional) Explain why this change is being made +# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->| + +# (Optional) Provide links or keys to any relevant tickets, articles or other resources +# Example: Github issue #23 + +# --- COMMIT END --- +# +# Remember to: +# * Capitalize the subject line +# * Use the imperative mood in the subject line +# * Do not end the subject line with a period +# * Separate subject from body with a blank line +# * Use the body to explain what and why vs. how +# * Can use multiple lines with "-" or "*" for bullet points in body +# -------------------- + +# Continuous integration messages diff --git a/.gitignore b/.gitignore index 1a1a99c..52877ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ *.swp - +*.swo +.phpunit.result.cache /doxygen /pdf /tex /tmp - +/composer.lock +/vendor diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..cbadbc6 --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require-dev": { + "phpunit/phpunit": "^8.4" + } +} diff --git a/scripts/checkCodeQuality.sh b/scripts/checkCodeQuality.sh new file mode 100644 index 0000000..785592f --- /dev/null +++ b/scripts/checkCodeQuality.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Ensure that phpcs is available on the system. + +if ! [ -x "$(command -v phpcs)" ]; then + echo "This script needs phpcs installed to run!" + exit 1; +fi + +# Load environment and load list of relevant instances. + +SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" + +# Run PHPCS + +PHPCS_RESULT=$(phpcs --standard=~/Rules/md_Rules/md_phpcs_rules.xml "$SCRIPT_DIR/../*.php" | grep " | " | wc -l) + +for i in "$SCRIPT_DIR/../"*; do + if [ "$(echo $i | grep -v "musdb" | wc -l)" = "0" ]; then + continue + fi + PHPCS_RESULT=$(echo "$(phpcs --standard=~/Rules/md_Rules/md_phpcs_rules.xml $i/*.php | grep " | " | wc -l) + $PHPCS_RESULT" | bc) +done + +# PHPCS_RESULT=$(echo "$(phpcs --standard=~/Rules/md_Rules/md_phpcs_rules.xml "$SCRIPT_DIR/../*/*.php" | grep " | " | wc -l) + $PHPCS_RESULT" | bc) + +echo "phpcs-errors:$PHPCS_RESULT"; + +# Run PHPUnit + +PHPUNIT_TEST_BASE_DIR="/var/www/vhosts/museum-digital.de/about.museum-digital.de" + +$(php $PHPUNIT_TEST_BASE_DIR/vendor/bin/phpunit --stderr -c $PHPUNIT_TEST_BASE_DIR/tests/config.xml --testdox $PHPUNIT_TEST_BASE_DIR/tests) +PHPUNIT_EC=$? +echo "" +if [ "$PHPUNIT_EC" = "1" ]; then + echo "phpunit-status:failing"; +else + echo "phpunit-status:successful"; +fi diff --git a/tests/config.xml b/tests/config.xml new file mode 100644 index 0000000..b828b98 --- /dev/null +++ b/tests/config.xml @@ -0,0 +1,37 @@ + + + + ../home/ + ../inc/ + + + + + diff --git a/tests/startPageTest.php b/tests/startPageTest.php new file mode 100644 index 0000000..57cc8e9 --- /dev/null +++ b/tests/startPageTest.php @@ -0,0 +1,29 @@ + + */ +declare(strict_types=1); + +// phpcs:disable + +use PHPUnit\Framework\TestCase; + +final class StartPageTest extends TestCase { + + public function testHTMLOutput():void { + + include __DIR__ . "/../index.php"; + $output = $this->getActualOutput(); + + $this->assertEquals( + true, + is_string($output) + ); + + ob_clean(); + + } + +}