File tree Expand file tree Collapse file tree 5 files changed +153
-7
lines changed Expand file tree Collapse file tree 5 files changed +153
-7
lines changed Original file line number Diff line number Diff line change 45
45
# Extension name, taken from .info file.
46
46
extension=" $( basename -s .info.yml -- ./* .info.yml) "
47
47
[ " ${extension} " == " *" ] && fail " ERROR: No .info.yml file found." && exit 1
48
+ extension_type=" module"
49
+ if cat " ${extension} .info.yml" | grep -Fq " type: theme" ; then
50
+ extension_type=" theme"
51
+ fi
48
52
49
53
# Database file path.
50
54
db_file=" /tmp/site_${extension} .sqlite"
@@ -56,7 +60,11 @@ pass "Drupal installed."
56
60
drush status
57
61
58
62
info " Enabling extension ${extension} ."
59
- drush pm:enable " ${extension} " -y
63
+ if [ " ${extension_type} " = " theme" ]; then
64
+ drush theme:enable " ${extension} " -y
65
+ else
66
+ drush pm:enable " ${extension} " -y
67
+ fi
60
68
61
69
info " Clearing caches."
62
70
drush cr
Original file line number Diff line number Diff line change 34
34
- name : Setup kcov
35
35
run : wget https://github.com/SimonKagstrom/kcov/releases/download/v42/kcov-amd64.tar.gz && tar -xf kcov-amd64.tar.gz && sudo mv ./usr/local/bin/kcov /usr/local/bin/kcov && kcov --version
36
36
37
+ - name : Install Ahoy
38
+ run : |
39
+ os=$(uname -s | tr '[:upper:]' '[:lower:]') && architecture=$(case $(uname -m) in x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac)
40
+ sudo wget -q https://github.com/ahoy-cli/ahoy/releases/download/v2.1.1/ahoy-bin-"${os}-${architecture}" -O /usr/local/bin/ahoy
41
+ sudo chown "$USER" /usr/local/bin/ahoy && chmod +x /usr/local/bin/ahoy
42
+
37
43
- name : Install dependencies
38
44
run : npm ci
39
45
working-directory : .scaffold/tests
Original file line number Diff line number Diff line change @@ -120,21 +120,21 @@ assert_workflow() {
120
120
121
121
pushd " ${dir} " > /dev/null || exit 1
122
122
123
+ # Very basic workflow.
123
124
./.devtools/assemble.sh
125
+ ./.devtools/start.sh
126
+ ./.devtools/provision.sh
124
127
125
- # Lint.
126
128
pushd " build" > /dev/null || exit 1
127
-
129
+ # Lint.
128
130
vendor/bin/phpcs
129
131
vendor/bin/phpstan
130
132
vendor/bin/rector --clear-cache --dry-run
131
133
vendor/bin/phpmd . text phpmd.xml
132
134
vendor/bin/twig-cs-fixer
133
-
135
+ # Test.
136
+ vendor/bin/phpunit
134
137
popd > /dev/null || exit 1
135
138
136
- # Change mode to make bats have enough permission to clean tmp test directory.
137
- chmod -R 777 " build/web/sites/default"
138
-
139
139
popd > /dev/null || exit 1
140
140
}
Original file line number Diff line number Diff line change @@ -56,6 +56,15 @@ setup() {
56
56
}
57
57
58
58
teardown () {
59
+ # Some tests start php in background, we need kill it for bats able to finish the test.
60
+ # This make break tests in parallel.
61
+ killall -9 php > /dev/null 2>&1 || true
62
+ sleep 1
63
+ # Give bats enought permission to clean the build dir.
64
+ if [ -d " build" ]; then
65
+ chmod -Rf 777 build > /dev/null || true
66
+ fi
67
+
59
68
# Move back to the original directory.
60
69
popd > /dev/null || cd " ${CUR_DIR} " || exit 1
61
70
}
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bats
2
+
3
+ load _helper
4
+
5
+ export BATS_FIXTURE_EXPORT_CODEBASE_ENABLED=1
6
+
7
+ @test " ahoy assemble" {
8
+ run ahoy assemble
9
+ assert_success
10
+
11
+ assert_output_contains " ASSEMBLE COMPLETE"
12
+ assert_dir_exists " ${BUILD_DIR} /build/vendor"
13
+ assert_file_exists " ${BUILD_DIR} /build/composer.json"
14
+ assert_file_exists " ${BUILD_DIR} /build/composer.lock"
15
+ }
16
+
17
+ @test " ahoy start" {
18
+ run ahoy start
19
+ assert_failure
20
+
21
+ ahoy assemble
22
+ run ahoy start
23
+ assert_success
24
+
25
+ assert_output_contains " ENVIRONMENT READY"
26
+ }
27
+
28
+ @test " ahoy stop" {
29
+ run ahoy stop
30
+ assert_success
31
+ assert_output_contains " ENVIRONMENT STOPPED"
32
+
33
+ ahoy assemble
34
+ ahoy start
35
+
36
+ run ahoy stop
37
+ assert_success
38
+
39
+ assert_output_contains " ENVIRONMENT STOPPED"
40
+ }
41
+
42
+ @test " ahoy lint, lint-fix" {
43
+ ahoy assemble
44
+ assert_success
45
+
46
+ ahoy lint
47
+ assert_success
48
+
49
+ # shellcheck disable=SC2016
50
+ echo ' $a=123;echo $a;' >> your_extension.module
51
+ run ahoy lint
52
+ assert_failure
53
+
54
+ run ahoy lint-fix
55
+ run ahoy lint
56
+ assert_success
57
+ }
58
+
59
+ @test " ahoy build - basic workflow" {
60
+ run ahoy build
61
+ assert_success
62
+ assert_output_contains " PROVISION COMPLETE"
63
+
64
+ run ahoy drush status
65
+ assert_success
66
+ assert_output_contains " Database : Connected"
67
+ assert_output_contains " Drupal bootstrap : Successful"
68
+
69
+ run ahoy login
70
+ assert_success
71
+ assert_output_contains " user/reset/1/"
72
+
73
+ ahoy lint
74
+ assert_success
75
+
76
+ ahoy test
77
+ assert_success
78
+
79
+ ahoy test-unit
80
+ assert_success
81
+
82
+ ahoy test-kernel
83
+ assert_success
84
+
85
+ ahoy test-functional
86
+ assert_success
87
+ }
88
+
89
+ @test " ahoy test unit failure" {
90
+ run ahoy assemble
91
+ assert_success
92
+
93
+ run ahoy test-unit
94
+ assert_success
95
+
96
+ sed -i -e " s/assertEquals/assertNotEquals/g" " ${BUILD_DIR} /tests/src/Unit/YourExtensionServiceUnitTest.php"
97
+ run ahoy test-unit
98
+ assert_failure
99
+ }
100
+
101
+ @test " ahoy test functional failure" {
102
+ run ahoy build
103
+ assert_success
104
+
105
+ run ahoy test-functional
106
+ assert_success
107
+
108
+ sed -i -e " s/responseContains/responseNotContains/g" " ${BUILD_DIR} /tests/src/Functional/YourExtensionFunctionalTest.php"
109
+ run ahoy test-functional
110
+ assert_failure
111
+ }
112
+
113
+ @test " ahoy test kernel failure" {
114
+ run ahoy build
115
+ assert_success
116
+
117
+ run ahoy test-kernel
118
+ assert_success
119
+
120
+ sed -i -e " s/assertEquals/assertNotEquals/g" " ${BUILD_DIR} /tests/src/Kernel/YourExtensionServiceKernelTest.php"
121
+ run ahoy test-kernel
122
+ assert_failure
123
+ }
You can’t perform that action at this time.
0 commit comments