This repository was archived by the owner on Oct 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathbefore_tests.sh
More file actions
55 lines (44 loc) · 1.81 KB
/
before_tests.sh
File metadata and controls
55 lines (44 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# ==============================================================================
# BEFORE TESTS
# Tasks to run before functional testing.
# ==============================================================================
printf "\033[1;33mPerforming pre-test steps...\033[00m\n"
cd /var/www/vagrant/html
# Clear out localhost from flood table (prevents "more than 5 failed login attempts" error)
echo "Clearing localhost from flood table..."
drush sql-query "DELETE FROM flood WHERE identifier LIKE '%127.0.0.1';"
# Create fresh test accounts
drush_get_uid_from_email() {
drush user-information $1 | grep "User ID" | sed -e 's/[ ]*User ID[ ]*\:[ ]*//g' | sed -e 's/[ ]*//g'
}
drush_create_test_user() {
USERNAME=$1
drush user-create $USERNAME --mail="$USERNAME@example.com" --password="$USERNAME"
}
drush_delete_user_with_email() {
uid=$(drush_get_uid_from_email $1)
{
if [[ $uid -ne 0 ]]
then
drush user-cancel "$uid" -y --quiet
fi
} &> /dev/null
}
drush_signup_user() {
uid=$(drush_get_uid_from_email $2)
drush php-eval "dosomething_signup_create($1, $uid)"
}
echo "Deleting users created during previous test runs..."
drush_delete_user_with_email QA_TEST_ACCOUNT@example.com
drush_delete_user_with_email QA_TEST_USER_REGISTER@example.com
drush_delete_user_with_email QA_TEST_CAMPAIGN_SIGNUP_EXISTING@example.com
drush_delete_user_with_email QA_TEST_CAMPAIGN_SIGNUP_NEW@example.com
drush_delete_user_with_email QA_TEST_CAMPAIGN_ACTION@example.com
echo "Making fresh test accounts..."
drush_create_test_user QA_TEST_ACCOUNT
drush_create_test_user QA_TEST_CAMPAIGN_SIGNUP_EXISTING
drush_create_test_user QA_TEST_CAMPAIGN_ACTION
echo "Signing action page test account up for test campaign..."
example_campaign_nid=1261
drush_signup_user $example_campaign_nid QA_TEST_CAMPAIGN_ACTION@example.com