Skip to content

unit test

Yosuke Kushida edited this page Mar 6, 2019 · 1 revision

必要なもの

pdo-sqlite と MySQLサーバが必要。

環境設定

phpunit.xml の以下環境変数にMySQLサーバの情報を書く。

[08:16:33 pen@gray2 dbunit]$ git diff master -- phpunit.xml
diff --git a/phpunit.xml b/phpunit.xml
index 7f24b77..25a1405 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -15,9 +15,9 @@

     <php>
         <const name="PHPUNIT_TESTSUITE" value="true"/>
-        <!--<const name="PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_DSN" value="mysql:host=127.0.0.1;dbname=phpunit_tests;port=3306"/>-->
-        <!--<const name="PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_USERNAME" value="root"/>-->
-        <!--<const name="PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_PASSWORD" value=""/>-->
+        <const name="PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_DSN" value="mysql:host=127.0.0.1;dbname=phpunit_tests;port=3306"/>
+        <const name="PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_USERNAME" value="dbuser"/>
+        <const name="PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_PASSWORD" value="dbpass"/>
     </php>

     <filter>

実行

./vendor/bin/phpunit

Clone this wiki locally