isRunning() public method

Check whether the embedded server is currently running.
public isRunning ( ) : boolean
return boolean true, if the server is running, otherwise false.
示例#1
0
 /**
  * @covers EmbeddedServer
  */
 public function testStartStopIsRunning()
 {
     // Check whether the server is currently running.
     $running = $this->embeddedServer->isRunning();
     if ($running) {
         // If the server is running we stop it, then start it.
         // Stop the server.
         self::assertTrue($this->embeddedServer->stopAndWait());
         // Restart the server.
         self::assertTrue($this->embeddedServer->start());
         self::assertTrue($this->embeddedServer->isRunning());
     } else {
         // If the server is stopped, we start it, then stop it.
         // Start the server.
         self::assertTrue($this->embeddedServer->start());
         self::assertTrue($this->embeddedServer->isRunning());
         // Stop the server.
         self::assertTrue($this->embeddedServer->stopAndWait());
     }
 }
 /**
  * SCENARIO: solr process admin button (solr not running)
  *   GIVEN I am in an environment that allows execution of solr server
  *         process management shell scripts from within PHP
  *     AND solr binaries have been installed within the plugin's
  *         "lib" directory
  *     AND no solr process is running on the local machine
  *    WHEN I open up the lucene plugin settings page
  *    THEN I'll see a button "Start Server".
  *
  * SCENARIO: start embedded solr server
  *   GIVEN I see the button "Stop Server" on the lucene plugin
  *         search settings page
  *    WHEN I click on this button
  *    THEN a solr server process will be started.
  *
  * SCENARIO: solr process admin button (solr running)
  *   GIVEN I am in an environment that allows execution of solr server
  *         process management shell scripts from within PHP
  *     AND I configured a solr server endpoint on "localhost"
  *     AND a solr process is running on the local machine
  *     AND the PID-file of the process is in the installation's
  *         files direcory
  *    WHEN I open up the lucene plugin settings page
  *    THEN I'll see a button "Stop Server".
  *
  * SCENARIO: stop embedded solr server
  *   GIVEN I see the button "Stop Server" on the lucene plugin
  *         search settings page
  *    WHEN I click on this button
  *    THEN the running solr process will be stopped.
  */
 public function testSolrServerStartStopButtons()
 {
     // Stop the solr server. (This is part of the
     // test but will also implicitly make sure that
     // the server doesn't run under the wrong user
     // which would make it unavailable to the web
     // frontend.)
     import('plugins/generic/lucene/classes/EmbeddedServer');
     $embeddedServer = new EmbeddedServer();
     $embeddedServer->stopAndWait();
     // Make sure that the server really stopped.
     // NB: If this fails then make sure that the server is
     // not running under a user different from the test user.
     // If that's the case we cannot stop the running server
     // and you'll have to stop it manually.
     self::assertFalse($embeddedServer->isRunning(), 'Embedded server still running.');
     // Open the lucene plugin settings page.
     $this->logIn();
     $this->verifyAndOpen($this->_pluginSettings . '#indexAdmin');
     // Check that no availability warning is shown.
     $this->waitForElementNotPresent('serverNotAvailable');
     // Check that a start button appears.
     $this->assertElementPresent('name=startServer');
     $this->assertElementNotPresent('name=stopServer');
     // Click on the start button.
     $this->clickAndWait('name=startServer');
     // Check that an embedded solr process is now running.
     self::assertTrue($embeddedServer->isRunning());
     // Check that a stop button appears.
     $this->assertElementPresent('name=stopServer');
     $this->assertElementNotPresent('name=startServer');
     // Click on the stop button.
     $this->clickAndWait('name=stopServer');
     // Check that the embedded solr process was stopped.
     self::assertFalse($embeddedServer->isRunning());
     // Restart the server from the test user so that it
     // is available for other tests.
     $this->startSolrServer($embeddedServer);
 }