Skip to content

Commit 1065d6e

Browse files
committed
Added setup-auth to tests.
1 parent 2e76ac3 commit 1065d6e

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

.travis/test_create.sh

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ trap print_errors EXIT
1717
php $XATAFACE/tools/create.php testapp
1818
cd testapp/bin
1919
bash install-module.sh calendar 1.0
20+
bash setup-auth.sh

Dataface/Application.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,11 @@ function __construct($conf = null) {
890890
$_REQUEST['-lang'] = basename($_REQUEST['-lang']);
891891
$this->_conf['lang'] = $_REQUEST['-lang'];
892892
if ( @$_COOKIE[$prefix.'lang'] !== $_REQUEST['-lang'] ){
893-
setcookie($prefix.'lang', $_REQUEST['-lang'], null, '/');
893+
if (php_sapi_name() === 'cli') {
894+
//fwrite(STDERR, "\nNOTICE: Running in CLI mode mode, so not setting language cookie\n");
895+
} else {
896+
setcookie($prefix.'lang', $_REQUEST['-lang'], null, '/');
897+
}
894898
}
895899
} else if (isset( $_COOKIE[$prefix.'lang']) ){
896900
$this->_conf['lang'] = $_COOKIE[$prefix.'lang'];
@@ -902,7 +906,11 @@ function __construct($conf = null) {
902906
$this->getAvailableLanguages()
903907
)
904908
);
905-
setcookie($prefix.'lang', $this->_conf['lang'], null, '/');
909+
if (php_sapi_name() === 'cli') {
910+
//fwrite(STDERR, "\nNOTICE: Running in CLI mode so not setting the lang cookie.\n");
911+
} else {
912+
setcookie($prefix.'lang', $this->_conf['lang'], null, '/');
913+
}
906914
}
907915

908916
$this->_conf['lang'] = basename($this->_conf['lang']);

public-api.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,8 @@ function df_q($sql){
875875
} else {
876876
$res = xf_db_query($sql, df_db());
877877
if ( !$res ){
878-
error_log("Error executing SQL: $sql");
879-
error_log(xf_db_error(df_db()));
878+
//error_log("Error executing SQL: $sql");
879+
//error_log(xf_db_error(df_db()));
880880
throw new Exception(xf_db_error(df_db()));
881881
}
882882
return $res;

scaffold_template/bin/inc/setup-auth.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
echo "Setting up authentication on app...\n";
23
chdir(dirname(__FILE__).'/../../app');
34
require_once 'xataface/public-api.php';
45
df_init(dirname(__FILE__).'/../../app/index.php', 'xataface');
@@ -144,14 +145,14 @@
144145

145146
echo "Adding default admin user...";
146147
chdir("../bin");
147-
exec("sh add-user.sh admin '[email protected]' ADMIN password", $buffer, $res);
148+
exec("bash add-user.sh admin '[email protected]' ADMIN password", $buffer, $res);
148149
if ($res !== 0) {
149150
fwrite(STDERR, "Failed\n");
150151
print_r($buffer);
151152
exit(1);
152153
}
153-
echo "Done. User 'admin' created with password 'password'\n";
154-
echo "You should change this user's password after logging in.";
154+
echo "Done.\nUser 'admin' created with password 'password'\n";
155+
echo "You should change this user's password after logging in.\n";
155156
chdir("../app");
156157

157158

scaffold_template/bin/setup-auth.sh

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
#!/bin/bash
2+
echo "Setting up auth..."
3+
set -e
24
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
35
TABLES_DIR=$SCRIPTPATH/../app/tables
46
[ -d "$TABLES_DIR" ] || mkdir "$TABLES_DIR"
5-
6-
status=`bash $SCRIPTPATH/mysql.server.sh status`
7-
if [[ $status == *"ERROR!"* ]]; then
8-
$SCRIPTPATH/mysql.server.sh start || (echo "Failed to start mysql" && exit 1)
7+
echo "Checking mysql server status..."
8+
set +e
9+
bash $SCRIPTPATH/mysql.server.sh status
10+
status=$?
11+
set -e
12+
echo "$status\n"
13+
if [[ $status != 0 ]]; then
14+
bash $SCRIPTPATH/mysql.server.sh start || (echo "Failed to start mysql" && exit 1)
915
function finish() {
10-
$SCRIPTPATH/mysql.server stop
16+
bash $SCRIPTPATH/mysql.server.sh stop
1117
}
1218
trap finish EXIT
1319
fi

0 commit comments

Comments
 (0)