| 
									
										
										
										
											2016-01-16 09:15:24 +01:00
										 |  |  | #!/bin/bash
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # set testing environment | 
					
						
							|  |  |  | cp .env.testing .env | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-19 18:09:53 +01:00
										 |  |  | # set default phpunit. | 
					
						
							|  |  |  | cp phpunit.default.xml phpunit.xml | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-20 10:47:29 +01:00
										 |  |  | # "create" default attachment: | 
					
						
							|  |  |  | touch storage/upload/at-1.data | 
					
						
							|  |  |  | touch storage/upload/at-2.data | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-19 16:55:02 +01:00
										 |  |  | # delete test databases: | 
					
						
							|  |  |  | if [ -f storage/database/testing.db ] | 
					
						
							| 
									
										
										
										
											2016-01-16 09:15:24 +01:00
										 |  |  | then | 
					
						
							| 
									
										
										
										
											2016-01-19 16:55:02 +01:00
										 |  |  |     rm storage/database/testing.db | 
					
						
							| 
									
										
										
										
											2016-01-16 09:15:24 +01:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-19 16:55:02 +01:00
										 |  |  | if [ -f storage/database/testing-copy.db ] | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |     rm storage/database/testing-copy.db | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # test! | 
					
						
							| 
									
										
										
										
											2016-01-22 22:39:51 +01:00
										 |  |  | if [ -z "$1" ] | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |     echo "Running all tests..." | 
					
						
							|  |  |  |     phpunit | 
					
						
							| 
									
										
										
										
											2016-01-24 15:55:48 +01:00
										 |  |  |     result=$? | 
					
						
							| 
									
										
										
										
											2016-01-22 22:39:51 +01:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # test selective.. | 
					
						
							|  |  |  | dirs=("acceptance/Controllers" "acceptance/Controllers/Auth" "acceptance/Controllers/Chart" "unit") | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | if [ ! -z "$1" ] | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |     for i in "${dirs[@]}" | 
					
						
							|  |  |  |     do | 
					
						
							|  |  |  |         firstFile="./tests/$i/$1.php" | 
					
						
							|  |  |  |         secondFile="./tests/$i/$1Test.php" | 
					
						
							|  |  |  |         if [ -f "$firstFile" ] | 
					
						
							|  |  |  |         then | 
					
						
							|  |  |  |             # run it! | 
					
						
							|  |  |  |             echo "Now running $firstFile" | 
					
						
							|  |  |  |             phpunit --verbose $firstFile | 
					
						
							| 
									
										
										
										
											2016-01-24 15:55:48 +01:00
										 |  |  |             result=$? | 
					
						
							| 
									
										
										
										
											2016-01-22 22:39:51 +01:00
										 |  |  |         fi | 
					
						
							|  |  |  |         if [ -f "$secondFile" ] | 
					
						
							|  |  |  |         then | 
					
						
							|  |  |  |             # run it! | 
					
						
							|  |  |  |             echo "Now running $secondFile" | 
					
						
							|  |  |  |             phpunit --verbose $secondFile | 
					
						
							| 
									
										
										
										
											2016-01-24 15:55:48 +01:00
										 |  |  |             result=$? | 
					
						
							| 
									
										
										
										
											2016-01-22 22:39:51 +01:00
										 |  |  |         fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     done | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-16 09:15:24 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | # restore .env file | 
					
						
							|  |  |  | cp .env.local .env | 
					
						
							| 
									
										
										
										
											2016-01-24 15:55:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | exit ${result} |