Add test database credentials to phpunit config to allow local overriding.

parent 98f13b08
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.6/phpunit.xsd" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap="./tests/Bootstrap.php" bootstrap="./tests/Bootstrap.php"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" backupStaticAttributes="false"
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
<php> <php>
<ini name="error_reporting" value="-1" /> <ini name="error_reporting" value="-1" />
<const name="PHPUNIT_TESTSUITE" value="true"/> <const name="PHPUNIT_TESTSUITE" value="true"/>
<const name="PHPUNIT_DB_HOST" value="127.0.0.1"/>
<const name="PHPUNIT_DB_NAME" value="telegrambot"/>
<const name="PHPUNIT_DB_USER" value="root"/>
<const name="PHPUNIT_DB_PASS" value=""/>
</php> </php>
<testsuites> <testsuites>
<testsuite name="Package Test Suite"> <testsuite name="Package Test Suite">
......
...@@ -22,7 +22,7 @@ CREATE TABLE IF NOT EXISTS `chat` ( ...@@ -22,7 +22,7 @@ CREATE TABLE IF NOT EXISTS `chat` (
KEY `old_id` (`old_id`) KEY `old_id` (`old_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
CREATE TABLE IF NOT EXISTS `user_chat` ( CREATE TABLE IF NOT EXISTS `user_chat` (
`user_id` bigint COMMENT 'Unique user identifier', `user_id` bigint COMMENT 'Unique user identifier',
`chat_id` bigint COMMENT 'Unique user or chat identifier', `chat_id` bigint COMMENT 'Unique user or chat identifier',
......
...@@ -34,14 +34,14 @@ class ConversationTest extends TestCase ...@@ -34,14 +34,14 @@ class ConversationTest extends TestCase
protected function setUp() protected function setUp()
{ {
$credentials = [ $credentials = [
'host' => '127.0.0.1', 'host' => PHPUNIT_DB_HOST,
'user' => 'root', 'database' => PHPUNIT_DB_NAME,
'password' => '', 'user' => PHPUNIT_DB_USER,
'database' => 'telegrambot', 'password' => PHPUNIT_DB_PASS,
]; ];
$this->telegram = new Telegram('testapikey', 'testbotname'); $this->telegram = new Telegram('testapikey', 'testbotname');
$this->telegram->enableMySQL($credentials); $this->telegram->enableMySql($credentials);
//Make sure we start with an empty DB for each test. //Make sure we start with an empty DB for each test.
TestHelpers::emptyDB($credentials); TestHelpers::emptyDB($credentials);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment