Add test for start page
phpcs-errors:1646 phpunit-status:successful
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,7 +1,10 @@ | |||||||
| /csv | /csv | ||||||
|  | /composer.lock | ||||||
| /translation-importer | /translation-importer | ||||||
| /values/langfiles | /values/langfiles | ||||||
| *.swp | *.swp | ||||||
| *.swo | *.swo | ||||||
| commonservices | commonservices | ||||||
|  | /vendor/ | ||||||
| /xml | /xml | ||||||
|  | .phpunit.result.cache | ||||||
|   | |||||||
							
								
								
									
										5
									
								
								composer.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								composer.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | |||||||
|  | { | ||||||
|  |     "require-dev": { | ||||||
|  |         "phpunit/phpunit": "^8.4" | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -79,7 +79,7 @@ foreach ($availableFields as $headline => $fields) { | |||||||
|         echo " |         echo " | ||||||
|         <li id='{$fieldName}' data-alt='{$field['name_human_readable']}' data-value='{$fieldName}' data-for='{$fieldName}' class='"; |         <li id='{$fieldName}' data-alt='{$field['name_human_readable']}' data-value='{$fieldName}' data-for='{$fieldName}' class='"; | ||||||
|         if ($hasTooltip === true) echo " newToolTipTag"; |         if ($hasTooltip === true) echo " newToolTipTag"; | ||||||
|         if ($field['required'] === true) echo " requiredField"; |         if (!empty($field['required']) and $field['required'] === true) echo " requiredField"; | ||||||
|         echo "'"; |         echo "'"; | ||||||
|         if (!empty($field['dependsOn'])) { |         if (!empty($field['dependsOn'])) { | ||||||
|             echo " data-dependencies='" . htmlspecialchars(implode(";", $field['dependsOn'])) . "'"; |             echo " data-dependencies='" . htmlspecialchars(implode(";", $field['dependsOn'])) . "'"; | ||||||
|   | |||||||
							
								
								
									
										40
									
								
								scripts/checkCodeQuality.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								scripts/checkCodeQuality.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -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/sandkasten.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 | ||||||
							
								
								
									
										30
									
								
								tests/apisRandomImagesTest.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								tests/apisRandomImagesTest.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | |||||||
|  | <?PHP | ||||||
|  | /** | ||||||
|  |  * This script contains tests for the home page. | ||||||
|  |  * | ||||||
|  |  * @author Joshua Ramon Enslin <joshua@jrenslin.de> | ||||||
|  |  */ | ||||||
|  | declare(strict_types=1); | ||||||
|  |  | ||||||
|  | // phpcs:disable | ||||||
|  |  | ||||||
|  | use PHPUnit\Framework\TestCase; | ||||||
|  |  | ||||||
|  | final class StartPageLoadsTest extends TestCase { | ||||||
|  |  | ||||||
|  |     public function testHTMLOutput():void { | ||||||
|  |  | ||||||
|  |         ob_start(); | ||||||
|  |         include __DIR__ . "/../index.php"; | ||||||
|  |         $output = $this->getActualOutput(); | ||||||
|  |  | ||||||
|  |         $this->assertEquals( | ||||||
|  |             true, | ||||||
|  |             is_string($output) | ||||||
|  |         ); | ||||||
|  |  | ||||||
|  |         ob_clean(); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										37
									
								
								tests/config.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								tests/config.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | |||||||
|  | <phpunit | ||||||
|  |         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||
|  |         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/|version|/phpunit.xsd" | ||||||
|  |         backupGlobals="true" | ||||||
|  |         backupStaticAttributes="false" | ||||||
|  |         cacheResult="true" | ||||||
|  |         cacheTokens="true" | ||||||
|  |         colors="false" | ||||||
|  |         convertErrorsToExceptions="false" | ||||||
|  |         convertNoticesToExceptions="false" | ||||||
|  |         convertWarningsToExceptions="false" | ||||||
|  |         forceCoversAnnotation="false" | ||||||
|  |         printerClass="PHPUnit\TextUI\ResultPrinter" | ||||||
|  |         processIsolation="true" | ||||||
|  |         stopOnError="true" | ||||||
|  |         stopOnFailure="true" | ||||||
|  |         stopOnIncomplete="true" | ||||||
|  |         stopOnSkipped="true" | ||||||
|  |         stopOnRisky="true" | ||||||
|  |         testSuiteLoaderClass="PHPUnit\Runner\StandardTestSuiteLoader" | ||||||
|  |         timeoutForSmallTests="1" | ||||||
|  |         timeoutForMediumTests="10" | ||||||
|  |         timeoutForLargeTests="60" | ||||||
|  |         verbose="false"> | ||||||
|  | 	<filter> | ||||||
|  | 		<whitelist processUncoveredFilesFromWhitelist="true"> | ||||||
|  | 			<directory suffix=".php">../home/</directory> | ||||||
|  | 			<directory suffix=".php">../inc/</directory> | ||||||
|  | 			<!-- <file>/path/to/file</file> | ||||||
|  | 			<exclude> | ||||||
|  | 				<directory suffix=".php">/path/to/files</directory> | ||||||
|  | 				<file>/path/to/file</file> | ||||||
|  | 			</exclude>--> | ||||||
|  | 		</whitelist> | ||||||
|  | 	</filter> | ||||||
|  | </phpunit> | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user