File tree Expand file tree Collapse file tree 3 files changed +76
-3
lines changed
Expand file tree Collapse file tree 3 files changed +76
-3
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # # #ddev-generated
4+ # # Description: This script is part of "tyler36/ddev-tinker". It's purpose is to download
5+ # # Psysh's PHP core documentation. After starting a "ddev tinker" session,
6+ # # type "doc date", where 'date' is any core PHP function. It will display a
7+ # # man-like page detailing the function.
8+ # # @see https://github.com/bobthecow/psysh/wiki/PHP-manual
9+ # # This addon does a "simple" (and naive) language check to see if the developer
10+ # # may prefer a different locale. See "Example" below to "fake" a non-English setup.
11+ # # Usage: get-php-manual
12+ # # Example: "ddev get-php-manual"
13+ # # Example: "LANG=ja_JP.UTF8 ddev get-php-manual"
14+
15+ mkdir -p " $DDEV_APPROOT /.ddev/homeadditions/.local/share/psysh"
16+
17+ FILENAME=php_manual.sqlite
18+ BASE_URL=" http://psysh.org/manual"
19+
20+ # # Parse the LANG and see if the developer has a non-English language
21+ case " ${LANG} " in
22+ de* )
23+ # # Assume German from "LANG=de_DE.UTF-8"
24+ MANUAL=" de/$FILENAME "
25+ ;;
26+ fr* )
27+ # # Assume French from "LANG=fr_FR.UTF-8"
28+ MANUAL=" fr/$FILENAME "
29+ ;;
30+ ja* )
31+ # # Assume Japanese from "LANG=ja_JP.UTF8"
32+ MANUAL=" ja/$FILENAME "
33+ ;;
34+ ru* )
35+ # # Assume Russian from "LANG=ru_RU.UTF-8"
36+ MANUAL=" ru/$FILENAME "
37+ ;;
38+ * )
39+ # # Default to English
40+ MANUAL=" en/$FILENAME "
41+ ;;
42+ esac
43+
44+ curl -sSL " $BASE_URL /$MANUAL " -o " $DDEV_APPROOT /.ddev/homeadditions/.local/share/psysh/$FILENAME "
Original file line number Diff line number Diff line change @@ -4,14 +4,14 @@ name: ddev-tinker
44# DDEV environment variables can be interpolated into these filenames
55project_files :
66- commands/web/tinker
7+ - commands/host/get-php-manual
78
89# DDEV environment variables can be interpolated into these actions
910post_install_actions :
1011- |
1112 #ddev-nodisplay
12- #ddev-description:Downloading English manual ...
13- mkdir -p ./homeadditions/.local/share/psysh
14- curl -sSL http://psysh.org/manual/en/php_manual.sqlite -o ./homeadditions/.local/share/psysh/php_manual.sqlite
13+ #ddev-description:Downloading PHP core manual
14+ ddev get-php-manual
1515
1616# Shell actions that can be done during removal of the add-on
1717removal_actions :
Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ health_checks() {
1616validate_tinker () {
1717 # Output should contain outcome
1818 ddev tinker ' print "tinker working " . 99+1' | grep ' working 100'
19+ # Manual should exist
20+ validate_php_manual
21+ }
22+
23+ validate_php_manual () {
1924 # Manual should exist
2025 test -f ${TESTDIR} /.ddev/homeadditions/.local/share/psysh/php_manual.sqlite || (printf " Failed to find manual in ${TESTDIR} \n" && exit 1)
2126}
@@ -38,6 +43,30 @@ teardown() {
3843 health_checks
3944}
4045
46+ @test " Non-English manuals can be installed" {
47+ set -eu -o pipefail
48+ cd ${TESTDIR}
49+ echo " # ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($( pwd) )" >&3
50+ ddev config --project-name=${PROJNAME}
51+ ddev get ${DIR}
52+ ddev restart
53+ validate_php_manual
54+
55+ # Grab the size of the file so we can compare it to another the second time.
56+ EN_SIZE=$( ddev . stat -c%s ' ~/.local/share/psysh/php_manual.sqlite' )
57+
58+ # Delete the file so we can change the language.
59+ rm " ${TESTDIR} /.ddev/homeadditions/.local/share/psysh/php_manual.sqlite"
60+
61+ # Change the language and get it again. NOTE: This requires a restart.
62+ LANG=" ja_JP.UTF-8" ddev get-php-manual
63+ ddev restart
64+ validate_php_manual
65+
66+ JA_SIZE=$( ddev . stat -c%s ' ~/.local/share/psysh/php_manual.sqlite' )
67+ [ $EN_SIZE != $JA_SIZE ]
68+ }
69+
4170@test " install from release" {
4271 set -eu -o pipefail
4372 cd ${TESTDIR} || ( printf " unable to cd to ${TESTDIR} \n" && exit 1 )
You can’t perform that action at this time.
0 commit comments