restart example

// Test that the route is not accessible as an anonymous user.     $this->drupalGet($protected_url);
    $session = $this->getSession();
    $this->assertSession()->statusCodeEquals(401);

    // We should be able to access the route with basic authentication.     $this->basicAuthGet($protected_url$this->user->getAccountName()$this->user->passRaw);
    $this->assertSession()->statusCodeEquals(200);

    // Check that the correct user is logged in.     $this->assertEquals($this->user->id()json_decode($session->getPage()->getContent())->user, 'The correct user is authenticated on a route with basic authentication.');
    $session->restart();

    // If we now try to access a page without basic authentication then we     // should no longer be logged in.     $this->drupalGet($unprotected_url);
    $this->assertSession()->statusCodeEquals(200);
    $this->assertEquals(0, json_decode($session->getPage()->getContent())->user, 'The user is no longer authenticated after visiting a page without basic authentication.');

    // If we access the protected page again without basic authentication we     // should get 401 Unauthorized.     $this->drupalGet($protected_url);
    $this->assertSession()->statusCodeEquals(401);
  }
$process = $this->getProcessForCode('sleep(32.1);');
        $process->start();
        posix_kill($process->getPid(), 9); // SIGKILL
        $process->wait();
    }

    public function testRestart()
    {
        $process1 = $this->getProcessForCode('echo getmypid();');
        $process1->run();
        $process2 = $process1->restart();

        $process2->wait(); // wait for output
        // Ensure that both processed finished and the output is numeric         $this->assertFalse($process1->isRunning());
        $this->assertFalse($process2->isRunning());
        $this->assertIsNumeric($process1->getOutput());
        $this->assertIsNumeric($process2->getOutput());

        // Ensure that restart returned a new process by check that the output is different         $this->assertNotEquals($process1->getOutput()$process2->getOutput());
    }
    // session-test/no-set.     $this->drupalGet('session-test/no-set/' . $value_2);
    $session = $this->getSession();
    $this->assertSession()->pageTextContains($value_2);
    // Verify that the session data is not saved for drupal_save_session(FALSE).     $this->drupalGet('session-test/get');
    $this->assertSession()->pageTextContains($value_1);

    // Switch browser cookie to anonymous user, then back to user 1.     $session_cookie_name = $this->getSessionName();
    $session_cookie_value = $session->getCookie($session_cookie_name);
    $session->restart();
    $this->initFrontPage();
    // Session restart always resets all the cookies by design, so we need to     // add the old session cookie again.     $session->setCookie($session_cookie_name$session_cookie_value);
    // Verify that the session data persists through browser close.     $this->drupalGet('session-test/get');
    $this->assertSession()->pageTextContains($value_1);
    $this->mink->setDefaultSessionName('default');

    // Logout the user and make sure the stored value no longer persists.     $this->drupalLogout();
    
$this->assertSame('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->reload() reloads the current page');
        $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->reload() keeps parameters');
        $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->reload() keeps files');
        $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->reload() keeps $_SERVER');
        $this->assertSame($content$client->getRequest()->getContent(), '->reload() keeps content');
    }

    public function testRestart()
    {
        $client = $this->getBrowser();
        $client->request('GET', 'http://www.example.com/foo/foobar');
        $client->restart();

        $this->assertTrue($client->getHistory()->isEmpty(), '->restart() clears the history');
        $this->assertSame([]$client->getCookieJar()->all(), '->restart() clears the cookies');
    }

    /** * @runInSeparateProcess */
    public function testInsulatedRequests()
    {
        $client = $this->getBrowser();
        
Home | Imprint | This part of the site doesn't use cookies.