Skip to content

Commit 8c7f0c8

Browse files
committed
Merge pull request firebase#34 from sarciszewski/patch-2
Add GnuPG verified phpunit script
2 parents 17c8e96 + 9ea3a22 commit 8c7f0c8

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

run-tests.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
#!/usr/bin/env bash
3+
clean=1 # Delete phpunit.phar after the tests are complete?
4+
gpg --fingerprint D8406D0D82947747293778314AA394086372C20A
5+
if [ $? -ne 0 ]; then
6+
echo -e "\033[33mDownloading PGP Public Key...\033[0m"
7+
gpg --recv-keys D8406D0D82947747293778314AA394086372C20A
8+
# Sebastian Bergmann <[email protected]>
9+
gpg --fingerprint D8406D0D82947747293778314AA394086372C20A
10+
if [ $? -ne 0 ]; then
11+
echo -e "\033[31mCould not download PGP public key for verification\033[0m"
12+
exit
13+
fi
14+
fi
15+
16+
if [ "$clean" -eq 1 ]; then
17+
# Let's clean them up, if they exist
18+
if [ -f phpunit.phar ]; then
19+
rm -f phpunit.phar
20+
fi
21+
if [ -f phpunit.phar.asc ]; then
22+
rm -f phpunit.phar.asc
23+
fi
24+
fi
25+
26+
# Let's grab the latest release and its signature
27+
if [ ! -f phpunit.phar ]; then
28+
wget https://phar.phpunit.de/phpunit.phar
29+
fi
30+
if [ ! -f phpunit.phar.asc ]; then
31+
wget https://phar.phpunit.de/phpunit.phar.asc
32+
fi
33+
34+
# Verify before running
35+
gpg --verify phpunit.phar.asc phpunit.phar
36+
if [ $? -eq 0 ]; then
37+
echo
38+
echo -e "\033[33mBegin Unit Testing\033[0m"
39+
# Run the testing suite
40+
phpunit --configuration phpunit.xml.dist
41+
# Cleanup
42+
if [ "$clean" -eq 1 ]; then
43+
echo -e "\033[32mCleaning Up!\033[0m"
44+
rm -f phpunit.phar
45+
rm -f phpunit.phar.asc
46+
fi
47+
else
48+
echo
49+
chmod -x phpunit.phar
50+
mv phpunit.phar /tmp/bad-phpunit.phar
51+
mv phpunit.phar.asc /tmp/bad-phpunit.phar.asc
52+
echo -e "\033[31mSignature did not match! PHPUnit has been moved to /tmp/bad-phpunit.phar\033[0m"
53+
exit 1
54+
fi

0 commit comments

Comments
 (0)