2015-10-06 71 views
1

我正在嘗試在Ubuntu 14.04上進行WordPress插件測試,我正在通過WP-CLI的設置,但我無法下載必要的文件(包括/ functions.php中)。(WP-CLI)Wordpress-Tests_Lib文件未被創建

這是我使用的命令:

bash bin/install-wp-tests.sh wordpress_test root '' localhost latest 

這是輸出:

+ install_wp 
+ '[' -d /tmp/wordpress/ ']' 
+ return 
+ install_test_suite 
++ uname -s 
+ [[ Linux == \D\a\r\w\i\n ]] 
+ local ioption=-i 
+ '[' '!' -d /tmp/wordpress-tests-lib ']' 
+ cd /tmp/wordpress-tests-lib 
+ '[' '!' -f wp-tests-config.php ']' 
+ download https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php /tmp/wordpress-tests-lib/wp-tests-config.php 
++ which curl 
+ '[' /opt/lampp/bin/curl ']' 
+ curl -s https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php 
+ sed -i 's:dirname(__FILE__) . '\''/src/'\'':'\''/tmp/wordpress/'\'':' /tmp/wordpress-tests-lib/wp-tests-config.php 
+ sed -i s/youremptytestdbnamehere/wordpress_test/ /tmp/wordpress-tests-lib/wp-tests-config.php 
+ sed -i s/yourusernamehere/root/ /tmp/wordpress-tests-lib/wp-tests-config.php 
+ sed -i s/yourpasswordhere// /tmp/wordpress-tests-lib/wp-tests-config.php 
+ sed -i 's|localhost|localhost|' /tmp/wordpress-tests-lib/wp-tests-config.php 
+ install_db 
+ PARTS=(${DB_HOST//\:/ }) 
+ local PARTS 
+ local DB_HOSTNAME=localhost 
+ local DB_SOCK_OR_PORT= 
+ local EXTRA= 
+ '[' -z localhost ']' 
++ echo 
++ grep -e '^[0-9]\{1,\}$' 
+ '[' ']' 
+ '[' -z ']' 
+ '[' -z localhost ']' 
+ EXTRA=' --host=localhost --protocol=tcp' 
+ mysqladmin create wordpress_test --user=root --password= --host=localhost --protocol=tcp 
Warning: Using a password on the command line interface can be insecure. 

使用它拋出一個錯誤PHPUnit命令:

Fatal error: require_once(): Failed opening required '/tmp/wordpress-tests-lib/includes/functions.php' (include_path='.:/opt/lampp/lib/php') 

我在辦公室,所以我認爲防火牆可以阻止這個命令,儘管我在/ etc/environment中設置了一個代理。

幫助表示讚賞。

+0

Wordpress無法使用PHPUnit進行測試。 –

+0

@ zdenek-machek - 你的發言是錯誤的。 PHPUnit用於測試核心,可以與WP-CLI一起使用。 – Pea

+0

你最終是否找到了解決方案? –

回答

0

我有同樣的問題;按照此處的說明解決它:https://github.com/wp-cli/wp-cli/wiki/Plugin-Unit-Tests。具體來說,我需要初始化測試環境。

bash bin/install-wp-tests.sh wordpress_test root '' localhost latest

其中wordpress_test是測試數據庫,root是DB用戶和''包含密碼。

更多資源:

1

我有這個問題,這裏是你可以嘗試什麼:

  1. 確認/tmp/wordpress-tests-lib缺少includes目錄。

  2. 確認您已安裝在機器上的svn。如果沒有運行sudo apt-get install subversion

  3. 刪除/tmp/wordpress-tests-lib文件夾

  4. 裏面你的插件目錄中打開了bin/install-wp-tests.sh文件並刪除在顛覆呼叫安靜標誌。更改此行:

    svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes 
    
    to 
    
    svn co https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes 
    
  5. 再次運行install shell腳本命令。

您現在應該可以運行PHPUnit並查看一個默認測試通過。

+0

謝謝,它還沒有解決問題。我正在處理第三方回購,但我很確定我添加的代碼是正確的,不管這個測試套件的問題 – MrMesees