From 599e1c7859ee1369b98d9ad825a26ca745e92810 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 21 Sep 2017 10:14:16 +0200 Subject: [PATCH 1/5] retrieve test server URI from environment --- tests/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a1793d32b3..cd8cc691a0 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -34,7 +34,7 @@ define('GLPI_CONFIG_DIR', __DIR__); define('GLPI_LOG_DIR', __DIR__ . '/files/_log'); -define('GLPI_URI', 'http://localhost:8088'); +define('GLPI_URI', (getenv('GLPI_URI') ?: 'http://localhost:8088')); define('TU_USER', '_test_user'); define('TU_PASS', 'PhpUnit_4'); From d3f2a000407a3f5066b89f5272359e97f49bca46 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 21 Sep 2017 10:26:21 +0200 Subject: [PATCH 2/5] fix test --- tests/units/NotificationEventAjax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/units/NotificationEventAjax.php b/tests/units/NotificationEventAjax.php index 814aae3deb..ef90f74f5e 100644 --- a/tests/units/NotificationEventAjax.php +++ b/tests/units/NotificationEventAjax.php @@ -167,7 +167,7 @@ public function testRaise() { 'replytoname' => null, 'headers' => '', 'body_html' => null, - 'body_text' => 'URL : http://localhost:8088/index.php?redirect=ticket_'.$ticket->getID().'&noAUTO=1 + 'body_text' => 'URL : ' . GLPI_URI . '/index.php?redirect=ticket_'.$ticket->getID().'&noAUTO=1 Ticket: Description From 374d28644abed93766698ffa15036680c9d4dbfc Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 21 Sep 2017 10:30:18 +0200 Subject: [PATCH 3/5] fix test, relying on "vendor" is terribly bad... --- tests/units/Config.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/units/Config.php b/tests/units/Config.php index 16865fcd46..8cbb570fab 100644 --- a/tests/units/Config.php +++ b/tests/units/Config.php @@ -247,10 +247,12 @@ public function testGetLibraryDir() { $this->boolean(\Config::getLibraryDir('abcde'))->isFalse(); $expected = realpath(__DIR__ . '/../../vendor/phpmailer/phpmailer'); - $this->string(\Config::getLibraryDir('PHPMailer'))->isIdenticalTo($expected); + if (is_dir($expected)) { // skip when system library is used + $this->string(\Config::getLibraryDir('PHPMailer'))->isIdenticalTo($expected); - $mailer = new \PHPMailer(); - $this->string(\Config::getLibraryDir($mailer))->isIdenticalTo($expected); + $mailer = new \PHPMailer(); + $this->string(\Config::getLibraryDir($mailer))->isIdenticalTo($expected); + } $expected = realpath(__DIR__ . '/../'); $this->string(\Config::getLibraryDir('getItemByTypeName'))->isIdenticalTo($expected); From efcf895548cb06667376f1ef6bc473f1299e069d Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 21 Sep 2017 10:36:10 +0200 Subject: [PATCH 4/5] fix --- tests/units/NotificationEventAjax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/units/NotificationEventAjax.php b/tests/units/NotificationEventAjax.php index ef90f74f5e..da1dabc600 100644 --- a/tests/units/NotificationEventAjax.php +++ b/tests/units/NotificationEventAjax.php @@ -167,7 +167,7 @@ public function testRaise() { 'replytoname' => null, 'headers' => '', 'body_html' => null, - 'body_text' => 'URL : ' . GLPI_URI . '/index.php?redirect=ticket_'.$ticket->getID().'&noAUTO=1 + 'body_text' => 'URL : ' . GLPI_URI . '/index.php?redirect=ticket_'.$ticket->getID().'&noAUTO=1 Ticket: Description From ae7b72cdcae66c063aee460d4939954a8988b66e Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 21 Sep 2017 10:54:33 +0200 Subject: [PATCH 5/5] create GLPI_SKIP_ONLINE --- tests/units/NotificationMailing.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/units/NotificationMailing.php b/tests/units/NotificationMailing.php index 3373143371..3f488df840 100644 --- a/tests/units/NotificationMailing.php +++ b/tests/units/NotificationMailing.php @@ -44,8 +44,10 @@ public function testCheck() { $this->boolean($instance->check('user'))->isFalse(); $this->boolean($instance->check('user@localhost'))->isTrue(); $this->boolean($instance->check('user@localhost.dot'))->isTrue(); - $this->boolean($instance->check('user@localhost.dot', ['checkdns' => true]))->isFalse(); - $this->boolean($instance->check('user@glpi-project.org', ['checkdns' => true]))->isTrue(); + if (!getenv('GLPI_SKIP_ONLINE')) { + $this->boolean($instance->check('user@localhost.dot', ['checkdns' => true]))->isFalse(); + $this->boolean($instance->check('user@glpi-project.org', ['checkdns' => true]))->isTrue(); + } } public function testSendNotification() {