From 1253928351c0931874c22aad55ae0b4e847f5222 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Tue, 7 Jun 2016 12:46:09 -0400
Subject: [PATCH] Removed Zombie.js testing tools. - The VuFind dev team now
 uses Selenium exclusively due to Zombie.js limitations. - This requires the
 removal of the assertHttpStatus method, since Selenium does not support it.

---
 build.xml                                     |  7 ++-
 composer.json                                 |  1 -
 .../src/VuFindTest/Unit/MinkTestCase.php      | 54 ++++---------------
 .../src/VuFindTest/Mink/BasicTest.php         |  1 -
 .../src/VuFindTest/Mink/RecordTest.php        |  1 -
 5 files changed, 12 insertions(+), 52 deletions(-)

diff --git a/build.xml b/build.xml
index 43f6f1602ba..42fd49f9e2c 100644
--- a/build.xml
+++ b/build.xml
@@ -7,7 +7,6 @@
   <property name="apacheconfdir" value="/etc/apache2/conf.d" />
   <property name="apachectl" value="false" /><!-- set to apachectl path to spin up Apache instance -->
   <property name="seleniumjar" value="false" /><!-- set to Selenium jar path to spin up Selenium instance -->
-  <property name="nodepath" value="" /><!-- set to node.js modules path to use Zombie.js testing -->
   <!-- command for extra cleanup during shutdown; e.g. to change cache ownership after testing w/ Apache so deletion won't fail: -->
   <property name="extra_shutdown_cleanup" value="false" />
   <property name="vufindurl" value="http://localhost/vufind" />
@@ -22,7 +21,7 @@
   <property name="pgsqlrootuser" value="postgres" />
   <property name="phpunit_extra_params" value="" />
   <property name="composer_extra_params" value="" />
-  <property name="mink_driver" value="zombiejs" /><!-- may also be set to selenium -->
+  <property name="mink_driver" value="selenium" />
   <property name="snooze_multiplier" value="1" /><!-- can be used to slow down tests (selenium only) -->
   <property name="php-cs-fixers" value="no_blank_lines_before_namespaces,function_call_space,trailing_spaces,unused_use,lowercase_keywords,encoding,parenthesis,php_closing_tag,visibility,duplicate_semicolon,extra_empty_lines,no_blank_lines_after_class_opening,no_empty_lines_after_phpdocs,operators_spaces,spaces_before_semicolon,ternary_spaces,concat_with_spaces,short_array_syntax,phpdoc_no_access,remove_leading_slash_use,eof_ending" />
 
@@ -116,12 +115,12 @@
 
   <!-- PHPUnit -->
   <target name="phpunit" description="Run tests">
-    <exec dir="${srcdir}/module/VuFind/tests" command="NODE_PATH=${nodepath} VUFIND_MINK_DRIVER=${mink_driver} VUFIND_SNOOZE_MULTIPLIER=${snooze_multiplier} VUFIND_LOCAL_DIR=${srcdir}/local VUFIND_URL=${vufindurl} ${srcdir}/vendor/bin/phpunit -dzend.enable_gc=0 --log-junit ${builddir}/reports/phpunit.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/ ${phpunit_extra_params}" passthru="true" checkreturn="true" />
+    <exec dir="${srcdir}/module/VuFind/tests" command="VUFIND_MINK_DRIVER=${mink_driver} VUFIND_SNOOZE_MULTIPLIER=${snooze_multiplier} VUFIND_LOCAL_DIR=${srcdir}/local VUFIND_URL=${vufindurl} ${srcdir}/vendor/bin/phpunit -dzend.enable_gc=0 --log-junit ${builddir}/reports/phpunit.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/ ${phpunit_extra_params}" passthru="true" checkreturn="true" />
   </target>
 
   <!-- PHPUnit without logging output -->
   <target name="phpunitfast" description="Run tests">
-    <exec dir="${srcdir}/module/VuFind/tests" command="NODE_PATH=${nodepath} VUFIND_MINK_DRIVER=${mink_driver} VUFIND_SNOOZE_MULTIPLIER=${snooze_multiplier} VUFIND_LOCAL_DIR=${srcdir}/local VUFIND_URL=${vufindurl} ${srcdir}/vendor/bin/phpunit -dzend.enable_gc=0 ${phpunit_extra_params}" passthru="true" checkreturn="true" />
+    <exec dir="${srcdir}/module/VuFind/tests" command="VUFIND_MINK_DRIVER=${mink_driver} VUFIND_SNOOZE_MULTIPLIER=${snooze_multiplier} VUFIND_LOCAL_DIR=${srcdir}/local VUFIND_URL=${vufindurl} ${srcdir}/vendor/bin/phpunit -dzend.enable_gc=0 ${phpunit_extra_params}" passthru="true" checkreturn="true" />
   </target>
 
   <target name="composer" description="Install dependencies with Composer">
diff --git a/composer.json b/composer.json
index c1bf155ce42..2acbe3d0c4e 100644
--- a/composer.json
+++ b/composer.json
@@ -36,7 +36,6 @@
     "require-dev": {
         "behat/mink": "1.7.0",
         "behat/mink-selenium2-driver": "1.3.0",
-        "behat/mink-zombie-driver": "1.3.0",
         "friendsofphp/php-cs-fixer": "1.11.3",
         "phploc/phploc": "2.0.6",
         "phpmd/phpmd": "1.5.0",
diff --git a/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php b/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php
index b84f20dfb5b..bc0f91e9ecc 100644
--- a/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php
+++ b/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php
@@ -27,7 +27,7 @@
  * @link     https://vufind.org/wiki/development:testing:unit_tests Wiki
  */
 namespace VuFindTest\Unit;
-use Behat\Mink\Driver\ZombieDriver, Behat\Mink\Session,
+use Behat\Mink\Driver\Selenium2Driver, Behat\Mink\Session,
     Behat\Mink\Element\Element,
     VuFind\Config\Locator as ConfigLocator,
     VuFind\Config\Writer as ConfigWriter;
@@ -115,31 +115,6 @@ abstract class MinkTestCase extends DbTestCase
         $writer->save();
     }
 
-    /**
-     * Are we using the Zombie.js driver?
-     *
-     * @return bool
-     */
-    protected function isZombieDriver()
-    {
-        return getenv('VUFIND_MINK_DRIVER') !== 'selenium';
-    }
-
-    /**
-     * Assert an HTTP status code (if supported).
-     *
-     * @param int $code Expected status code.
-     *
-     * @return void
-     */
-    protected function assertHttpStatus($code)
-    {
-        // This assertion is not supported by Selenium.
-        if ($this->isZombieDriver()) {
-            $this->assertEquals($code, $this->getMinkSession()->getStatusCode());
-        }
-    }
-
     /**
      * Sleep if necessary.
      *
@@ -149,14 +124,11 @@ abstract class MinkTestCase extends DbTestCase
      */
     protected function snooze($secs = 1)
     {
-        // Sleep is not necessary for Zombie.js.
-        if (!$this->isZombieDriver()) {
-            $snoozeMultiplier = intval(getenv('VUFIND_SNOOZE_MULTIPLIER'));
-            if ($snoozeMultiplier < 1) {
-                $snoozeMultiplier = 1;
-            }
-            sleep($secs * $snoozeMultiplier);
+        $snoozeMultiplier = intval(getenv('VUFIND_SNOOZE_MULTIPLIER'));
+        if ($snoozeMultiplier < 1) {
+            $snoozeMultiplier = 1;
         }
+        sleep($secs * $snoozeMultiplier);
     }
 
     /**
@@ -168,22 +140,17 @@ abstract class MinkTestCase extends DbTestCase
      */
     protected function checkVisibility(Element $element)
     {
-        // Zombie.js does not support visibility checks; just assume true.
-        return $this->isZombieDriver() ? true : $element->isVisible();
+        return $element->isVisible();
     }
 
     /**
      * Get the Mink driver, initializing it if necessary.
      *
-     * @return ZombieDriver
+     * @return Selenium2Driver
      */
     protected function getMinkDriver()
     {
-        return !$this->isZombieDriver()
-            ? new \Behat\Mink\Driver\Selenium2Driver('firefox')
-            : new ZombieDriver(
-                new \Behat\Mink\Driver\NodeJS\Server\ZombieServer()
-            );
+        return new Selenium2Driver('firefox');
     }
 
     /**
@@ -310,13 +277,10 @@ abstract class MinkTestCase extends DbTestCase
      */
     public function setUp()
     {
-        // Give up if we're not running in CI or Zombie.js is unavailable:
+        // Give up if we're not running in CI:
         if (!$this->continuousIntegrationRunning()) {
             return $this->markTestSkipped('Continuous integration not running.');
         }
-        if (strlen(getenv('NODE_PATH')) == 0) {
-            return $this->markTestSkipped('NODE_PATH setting missing.');
-        }
 
         // Reset the modified configs list.
         $this->modifiedConfigs = [];
diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/BasicTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/BasicTest.php
index 17a636e4fb6..96078903d7a 100644
--- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/BasicTest.php
+++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/BasicTest.php
@@ -47,7 +47,6 @@ class BasicTest extends \VuFindTest\Unit\MinkTestCase
     {
         $session = $this->getMinkSession();
         $session->visit($this->getVuFindUrl() . '/Search/Home');
-        $this->assertHttpStatus(200);
         $page = $session->getPage();
         $this->assertTrue(false !== strstr($page->getContent(), 'VuFind'));
     }
diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordTest.php
index 7e99ff45839..a88001c47f6 100644
--- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordTest.php
+++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordTest.php
@@ -53,7 +53,6 @@ class RecordTest extends \VuFindTest\Unit\MinkTestCase
         );
         $session = $this->getMinkSession();
         $session->visit($url);
-        $this->assertHttpStatus(200);
         $page = $session->getPage();
         $staffViewTab = $this->findCss($page, '.record-tabs .details');
         $this->assertEquals('Staff View', $staffViewTab->getText());
-- 
GitLab