• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Mink\Session类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Behat\Mink\Session的典型用法代码示例。如果您正苦于以下问题:PHP Session类的具体用法?PHP Session怎么用?PHP Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: openPage

 public function openPage($url)
 {
     $session = new Session($this->getDriver());
     $session->start();
     $session->visit($url);
     $this->page = $session->getPage();
 }
开发者ID:manasovdan,项目名称:eTextBookEditor,代码行数:7,代码来源:eTextBookDriver.php


示例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();
 }
开发者ID:molchanoviv,项目名称:Mink,代码行数:12,代码来源:Element.php


示例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]]);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:8,代码来源:CurrentPageResolverSpec.php


示例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');
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:8,代码来源:CookieSetterSpec.php


示例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;
 }
开发者ID:virtua-network,项目名称:qa-tools,代码行数:15,代码来源:PageFactory.php


示例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());
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:9,代码来源:BaseUrlTest.php


示例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'], '/') . '/');
 }
开发者ID:Mozan,项目名称:Sylius,代码行数:10,代码来源:CookieSetter.php


示例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();
 }
开发者ID:Andretti23,项目名称:Sylius,代码行数:10,代码来源:SecurityContext.php


示例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());
 }
开发者ID:Mangetsu,项目名称:Sylius,代码行数:14,代码来源:SecurityService.php


示例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' => '[email protected]'))->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 [email protected]')))->during('logIn', array('[email protected]', 'default', $minkSession));
 }
开发者ID:Spomky,项目名称:Sylius,代码行数:14,代码来源:SecurityServiceSpec.php


示例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));
 }
开发者ID:joemontibello,项目名称:vufind,代码行数:24,代码来源:RecordTest.php


示例12: stopMinkSession

 /**
  * Shut down the Mink session.
  *
  * @return void
  */
 protected function stopMinkSession()
 {
     if (!empty($this->session)) {
         $this->session->stop();
         $this->session = null;
     }
 }
开发者ID:grharry,项目名称:vufind,代码行数:12,代码来源:MinkTestCase.php


示例13: __construct

 /**
  * Initializes exception.
  *
  * @param string                  $message   optional message
  * @param DriverInterface|Session $driver    driver instance (or session for BC)
  * @param \Exception|null         $exception expectation exception
  */
 public function __construct($message, $driver, \Exception $exception = null)
 {
     if ($driver instanceof Session) {
         @trigger_error('Passing a Session object to the ExpectationException constructor is deprecated as of Mink 1.7. Pass the driver instead.', E_USER_DEPRECATED);
         $this->session = $driver;
         $this->driver = $driver->getDriver();
     } elseif (!$driver instanceof DriverInterface) {
         // Trigger an exception as we cannot typehint a disjunction
         throw new \InvalidArgumentException('The ExpectationException constructor expects a DriverInterface or a Session.');
     } else {
         $this->driver = $driver;
     }
     if (!$message && null !== $exception) {
         $message = $exception->getMessage();
     }
     parent::__construct($message, 0, $exception);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:24,代码来源:ExpectationException.php


示例14: checkUserAccessToPages

 /**
  * @param $not
  * @param TableNode $paths
  *
  * @throws \Exception
  *
  * @Given /^user should(| not) have an access to the following pages:$/
  */
 public function checkUserAccessToPages($not, TableNode $paths)
 {
     $result = [];
     $code = $not ? 403 : 200;
     // Use "GoutteDriver" to have an ability to check answer code.
     $driver = new Mink\Driver\GoutteDriver();
     $session = new Mink\Session($driver);
     $session->start();
     foreach (array_keys($paths->getRowsHash()) as $path) {
         $path = trim($path, '/');
         $session->visit($this->locatePath($path));
         if ($session->getStatusCode() !== $code) {
             $result[] = $path;
         }
     }
     if (!empty($result)) {
         throw new \Exception(sprintf('The following paths: "%s" are %s accessible!', implode(', ', $result), $not ? '' : 'not'));
     }
 }
开发者ID:spheresh,项目名称:behat-drupal-propeople-context,代码行数:27,代码来源:RedirectContext.php


示例15: login

 /**
  * @return $session 
  */
 public static function login($username, $password)
 {
     $driver = new GoutteDriver();
     $session = new Session($driver);
     $session->start();
     $session->visit('https://github.com/login');
     $page = $session->getPage();
     $form = $page->find('css', '.auth-form form');
     if (null === $form) {
         throw new \Exception('Couldn\'t locate the login form.');
     }
     $form->fillField('login_field', $username);
     $form->fillField('password', $password);
     $form->submit();
     // @todo need to check if successfully logged in here...
     $dumper = new Dumper();
     file_put_contents(__DIR__ . '/../settings.yml', $dumper->dump(['github' => ['username' => $username, 'password' => $password]], 2));
     return $session;
 }
开发者ID:sebastianwestberg,项目名称:Gitcommander,代码行数:22,代码来源:Auth.php


示例16: getSession

 /**
  * Creates Mink session using current session strategy and returns it.
  *
  * @return Session
  */
 public function getSession()
 {
     if ($this->_session) {
         return $this->_session;
     }
     $browser = $this->getBrowser();
     try {
         $this->_session = $this->getSessionStrategy()->session($browser);
         if ($this->getCollectCodeCoverageInformation()) {
             $this->_session->visit($browser->getBaseUrl());
         }
     } catch (DriverException $e) {
         $message = 'The Selenium Server is not active on host %s at port %s';
         $this->markTestSkipped(sprintf($message, $browser->getHost(), $browser->getPort()));
     }
     return $this->_session;
 }
开发者ID:mablae,项目名称:phpunit-mink,代码行数:22,代码来源:BrowserTestCase.php


示例17: 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');
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:14,代码来源:AbstractFrontendTest.php


示例18: 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;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:13,代码来源:NotificationAccessor.php


示例19: 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.');
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:16,代码来源:CurrentPageResolver.php


示例20: getCurrentPageWithForm

 /**
  * {@inheritdoc}
  * 
  * @throws \LogicException
  */
 public function getCurrentPageWithForm(CreatePageInterface $createPage, UpdatePageInterface $updatePage)
 {
     $routeParameters = $this->urlMatcher->match($this->session->getCurrentUrl());
     if (false !== strpos($routeParameters['_route'], 'create')) {
         return $createPage;
     }
     if (false !== strpos($routeParameters['_route'], 'update')) {
         return $updatePage;
     }
     throw new \LogicException('Route name does not have any of "update" or "create" keyword, so matcher was unable to match proper page.');
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:16,代码来源:CurrentPageResolver.php



注:本文中的Behat\Mink\Session类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Element\NodeElement类代码示例发布时间:2022-05-23
下一篇:
PHP Node\TableNode类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap