本文整理汇总了PHP中Behat\Mink\Session类的典型用法代码示例。如果您正苦于以下问题:PHP Session类的具体用法?PHP Session怎么用?PHP Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: openPage
public function openPage($url)
{
$session = new Session($this->getDriver());
$session->start();
$session->visit($url);
$this->page = $session->getPage();
}
示例2: __construct
/**
* Initialize element.
*
* @param Session $session
*/
public function __construct(Session $session)
{
$this->xpathManipulator = new Manipulator();
$this->session = $session;
$this->driver = $session->getDriver();
$this->selectorsHandler = $session->getSelectorsHandler();
}
示例3:
function it_throws_an_exception_if_neither_create_nor_update_key_word_has_been_found(Session $session, SymfonyPageInterface $createPage, SymfonyPageInterface $updatePage, UrlMatcherInterface $urlMatcher)
{
$session->getCurrentUrl()->willReturn('https://sylius.com/resource/show');
$urlMatcher->match('/resource/show')->willReturn(['_route' => 'sylius_resource_show']);
$createPage->getRouteName()->willReturn('sylius_resource_create');
$updatePage->getRouteName()->willReturn('sylius_resource_update');
$this->shouldThrow(\LogicException::class)->during('getCurrentPageWithForm', [[$createPage, $updatePage]]);
}
示例4:
function it_loads_base_url_and_sets_a_cookie_if_not_using_kernel_driver_and_driver_is_currently_outside_base_url(Session $minkSession, DriverInterface $driver)
{
$minkSession->getDriver()->willReturn($driver);
$minkSession->getCurrentUrl()->willReturn('http://sylius.org');
$minkSession->visit('http://localhost:8080/')->shouldBeCalled();
$minkSession->setCookie('abc', 'def')->shouldBeCalled();
$this->setCookie('abc', 'def');
}
示例5: attachSeleniumSelector
/**
* Attaches Selenium selector, that is later used during annotation processing.
*
* @param Session $session Mink session.
*
* @return self
*/
protected function attachSeleniumSelector(Session $session)
{
$selectors_handler = $session->getSelectorsHandler();
if (!$selectors_handler->isSelectorRegistered('se')) {
$selectors_handler->registerSelector('se', new SeleniumSelector($selectors_handler));
}
return $session;
}
示例6: testBaseUrl
public function testBaseUrl()
{
$client = new Client(require __DIR__ . '/../app.php');
$driver = new BrowserKitDriver($client, 'http://localhost/foo/');
$session = new Session($driver);
$session->visit('http://localhost/foo/index.html');
$this->assertEquals(200, $session->getStatusCode());
$this->assertEquals('http://localhost/foo/index.html', $session->getCurrentUrl());
}
示例7: prepareMinkSessionIfNeeded
private function prepareMinkSessionIfNeeded()
{
if ($this->minkSession->getDriver() instanceof KernelDriver) {
return;
}
if (false !== strpos($this->minkSession->getCurrentUrl(), $this->minkParameters['base_url'])) {
return;
}
$this->minkSession->visit(rtrim($this->minkParameters['base_url'], '/') . '/');
}
示例8: prepareSessionIfNeeded
private function prepareSessionIfNeeded()
{
if (!$this->minkSession->getDriver() instanceof Selenium2Driver) {
return;
}
if (false !== strpos($this->minkSession->getCurrentUrl(), $this->minkParameters['base_url'])) {
return;
}
$this->homePage->open();
}
示例9: logIn
/**
* {@inheritdoc}
*/
public function logIn($email, $providerKey, Session $minkSession)
{
$user = $this->userRepository->findOneBy(['username' => $email]);
if (null === $user) {
throw new \InvalidArgumentException(sprintf('There is no user with email %s', $email));
}
$token = new UsernamePasswordToken($user, $user->getPassword(), $providerKey, $user->getRoles());
$this->session->set('_security_user', serialize($token));
$this->session->save();
$minkSession->setCookie($this->session->getName(), $this->session->getId());
}
示例10: array
function it_does_not_log_user_in_if_user_was_not_found($userRepository, $session, UserInterface $user, Session $minkSession)
{
$userRoles = ['ROLE_USER'];
$userRepository->findOneBy(array('username' => 'sylius@example.com'))->willReturn(null);
$user->getRoles()->willReturn($userRoles);
$user->getPassword()->willReturn('xyz');
$user->serialize()->willReturn('serialized_user');
$session->set('_security_user', Argument::any())->shouldNotBeCalled();
$session->save()->shouldNotBeCalled();
$session->getName()->willReturn('MOCKEDSID');
$session->getId()->willReturn('xyzc123');
$minkSession->setCookie('MOCKEDSID', 'xyzc123')->shouldNotBeCalled();
$this->shouldThrow(new \InvalidArgumentException(sprintf('There is no user with email sylius@example.com')))->during('logIn', array('sylius@example.com', 'default', $minkSession));
}
示例11: tryRecordTabsOnId
/**
* Test record tabs for a particular ID.
*
* @param Session $session Session
* @param string $id ID to load
* @param bool $encodeId Should we URL encode the ID?
*
* @return void
*/
protected function tryRecordTabsOnId(Session $session, $id, $encodeId = true)
{
$url = $this->getVuFindUrl('/Record/' . ($encodeId ? rawurlencode($id) : $id));
$session->visit($url);
$this->assertEquals(200, $session->getStatusCode());
$page = $session->getPage();
$staffViewTab = $page->findById('details');
$this->assertTrue(is_object($staffViewTab));
$this->assertEquals('Staff View', $staffViewTab->getText());
$staffViewTab->click();
$this->assertEquals($url . '#details', $session->getCurrentUrl());
$staffViewTable = $page->find('css', '#details-tab table.citation');
$this->assertTrue(is_object($staffViewTable));
$this->assertEquals('LEADER', substr($staffViewTable->getText(), 0, 6));
}
示例12: stopMinkSession
/**
* Shut down the Mink session.
*
* @return void
*/
protected function stopMinkSession()
{
if (!empty($this->session)) {
$this->session->stop();
$this->session = null;
}
}
示例13: login
/**
* helper method for pages which needs an active login
*
* @throws ElementNotFoundException
*
* @return void
*/
protected function login()
{
$page = $this->session->getPage();
$page->fillField('email', 'root');
$page->fillField('password', 'developer');
$page->pressButton('Anmelden');
}
示例14: getMessageElement
/**
* @return NodeElement
*
* @throws ElementNotFoundException
*/
private function getMessageElement()
{
$messageElement = $this->session->getPage()->find('css', self::NOTIFICATION_ELEMENT_CSS);
if (null === $messageElement) {
throw new ElementNotFoundException($this->session->getDriver(), 'message element', 'css', self::NOTIFICATION_ELEMENT_CSS);
}
return $messageElement;
}
示例15: getCurrentPageWithForm
/**
* {@inheritdoc}
*
* @throws \LogicException
*/
public function getCurrentPageWithForm(array $pages)
{
$routeParameters = $this->urlMatcher->match(parse_url($this->session->getCurrentUrl(), PHP_URL_PATH));
Assert::allIsInstanceOf($pages, SymfonyPageInterface::class);
foreach ($pages as $page) {
if ($routeParameters['_route'] === $page->getRouteName()) {
return $page;
}
}
throw new \LogicException('Route name could not be matched to provided pages.');
}