isTerminated example


  protected function standUpServer($working_dir = NULL) {
    // If the user wants to test a new docroot, we have to shut down the old     // server process and generate a new port number.     if ($working_dir !== $this->serverDocroot && !empty($this->serverProcess)) {
      $this->stopServer();
    }
    // If there's not a server at this point, make one.     if (!$this->serverProcess || $this->serverProcess->isTerminated()) {
      $this->serverProcess = $this->instantiateServer($this->getPortNumber()$working_dir);
      if ($this->serverProcess) {
        $this->serverDocroot = $working_dir;
      }
    }
  }

  /** * Do the work of making a server process. * * Test authors should call visit() or assertVisit() instead. * * When initializing the server, if '.ht.router.php' exists in the root, it is * leveraged. If testing with a version of Drupal before 8.5.x., this file * does not exist. * * @param int $port * The port number for the server. * @param string|null $working_dir * (optional) Server docroot relative to the workspace filesystem. Defaults * to the workspace directory. * * @return \Symfony\Component\Process\Process * The server process. * * @throws \RuntimeException * Thrown if we were unable to start a web server. */
throw new LogicException(sprintf('Process must be started before calling "%s()".', $functionName));
        }
    }

    /** * Ensures the process is terminated, throws a LogicException if the process has a status different than "terminated". * * @throws LogicException if the process is not yet terminated */
    private function requireProcessIsTerminated(string $functionName): void
    {
        if (!$this->isTerminated()) {
            throw new LogicException(sprintf('Process must be terminated before calling "%s()".', $functionName));
        }
    }

    /** * Escapes a string to be used as a shell argument. */
    private function escapeArgument(?string $argument): string
    {
        if ('' === $argument || null === $argument) {
            return '""';
        }

        $process = $this->getProcess('echo foo');
        $process->run();
        $this->assertSame(0, $process->getExitCode());
    }

    public function testStatus()
    {
        $process = $this->getProcessForCode('usleep(100000);');
        $this->assertFalse($process->isRunning());
        $this->assertFalse($process->isStarted());
        $this->assertFalse($process->isTerminated());
        $this->assertSame(Process::STATUS_READY, $process->getStatus());
        $process->start();
        $this->assertTrue($process->isRunning());
        $this->assertTrue($process->isStarted());
        $this->assertFalse($process->isTerminated());
        $this->assertSame(Process::STATUS_STARTED, $process->getStatus());
        $process->wait();
        $this->assertFalse($process->isRunning());
        $this->assertTrue($process->isStarted());
        $this->assertTrue($process->isTerminated());
        $this->assertSame(Process::STATUS_TERMINATED, $process->getStatus());
    }

final class FiberCaster
{
    /** * @return array */
    public static function castFiber(\Fiber $fiber, array $a, Stub $stub, bool $isNested, int $filter = 0)
    {
        $prefix = Caster::PREFIX_VIRTUAL;

        if ($fiber->isTerminated()) {
            $status = 'terminated';
        } elseif ($fiber->isRunning()) {
            $status = 'running';
        } elseif ($fiber->isSuspended()) {
            $status = 'suspended';
        } elseif ($fiber->isStarted()) {
            $status = 'started';
        } else {
            $status = 'not started';
        }

        
throw new LogicException(sprintf('Process must be started before calling "%s()".', $functionName));
        }
    }

    /** * Ensures the process is terminated, throws a LogicException if the process has a status different than "terminated". * * @throws LogicException if the process is not yet terminated */
    private function requireProcessIsTerminated(string $functionName): void
    {
        if (!$this->isTerminated()) {
            throw new LogicException(sprintf('Process must be terminated before calling "%s()".', $functionName));
        }
    }

    /** * Escapes a string to be used as a shell argument. */
    private function escapeArgument(?string $argument): string
    {
        if ('' === $argument || null === $argument) {
            return '""';
        }

final class FiberCaster
{
    /** * @return array */
    public static function castFiber(\Fiber $fiber, array $a, Stub $stub, bool $isNested, int $filter = 0)
    {
        $prefix = Caster::PREFIX_VIRTUAL;

        if ($fiber->isTerminated()) {
            $status = 'terminated';
        } elseif ($fiber->isRunning()) {
            $status = 'running';
        } elseif ($fiber->isSuspended()) {
            $status = 'suspended';
        } elseif ($fiber->isStarted()) {
            $status = 'started';
        } else {
            $status = 'not started';
        }

        
Home | Imprint | This part of the site doesn't use cookies.