当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::submit方法代码示例

本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Client::submit方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::submit方法的具体用法?PHP Client::submit怎么用?PHP Client::submit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Bundle\FrameworkBundle\Client的用法示例。


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

示例1: loginAsUser

 /**
  * @return Crawler
  * @throws \Exception
  */
 protected static function loginAsUser()
 {
     $uri = self::$container->get('router')->generate('login_route');
     $crawler = self::$client->request('GET', $uri);
     $form = $crawler->selectButton('login_btn')->form(['_username' => 'test', '_password' => '12345678']);
     self::$client->submit($form);
     self::assertTrue(self::$client->getResponse()->isRedirection());
     return self::$client->followRedirect();
 }
开发者ID:Gemorroj,项目名称:forum,代码行数:13,代码来源:ForumWebTestCase.php

示例2: loginUsingFormUser

 /**
  * Use this function to connect to user in the application using login form
  * MORE SLOW, Use connectUser function above instead
  *
  * @param $username
  * @param $password
  * @return Client
  */
 protected function loginUsingFormUser($username, $password)
 {
     $this->client = static::createClient();
     $this->crawler = $this->client->request('GET', '/login');
     $credentials = array('_username' => $username, '_password' => $password);
     $form = $this->crawler->selectButton('_submit')->form($credentials);
     $this->client->submit($form);
     $this->client->followRedirects();
     return $this->client;
 }
开发者ID:TechGameCrew,项目名称:GyverProject,代码行数:18,代码来源:BaseTestCase.php

示例3: testRegisterSuccess

 public function testRegisterSuccess()
 {
     $this->form[self::USERNAME_FIELD] = self::USERNAME;
     $this->form[self::EMAIL_FIELD] = self::EMAIL;
     $this->form[self::PASSWORD_FIELD] = self::PASSWORD;
     $this->form[self::REPEAT_PASSWORD_FIELD] = self::PASSWORD;
     $this->crawler = $this->client->submit($this->form);
     $this->assertEmpty($this->crawler->filter(self::ERROR_SELECTOR));
     $this->assertNotEquals(self::REGISTRATION_URL, $this->client->getRequest()->getRequestUri());
 }
开发者ID:GrossumUA,项目名称:Symfony3-Base-Instance,代码行数:10,代码来源:RegistrationControllerTest.php

示例4: addBattery

 private function addBattery($type, $count, $name = null)
 {
     $crawler = $this->client->request('GET', '/add');
     $buttonCrawlerNode = $crawler->selectButton('Save');
     $form = $buttonCrawlerNode->form();
     $form['battery[type]'] = $type;
     $form['battery[count]'] = $count;
     $form['battery[name]'] = $name;
     $this->client->submit($form);
 }
开发者ID:turbovitalik,项目名称:battery,代码行数:10,代码来源:BatteryControllerTest.php

示例5: doLogin

 public function doLogin($username)
 {
     /** @var Crawler */
     $crawler = $this->client->request('GET', '/login');
     /** @var Response */
     $response = $this->client->getResponse();
     /** @var Form */
     $form = $crawler->selectButton('Login')->form();
     $form['_username'] = $username;
     $form['_password'] = 'supersecret';
     $crawler = $this->client->submit($form);
 }
开发者ID:ubermichael,项目名称:symftest,代码行数:12,代码来源:LOMWebTestCase.php

示例6: testLoginWithInvalidUser

 /**
  * Test form login with invalid user
  */
 public function testLoginWithInvalidUser()
 {
     $userName = 'invalidUserName';
     $password = 'invalidUserName';
     $crawler = $this->client->request('GET', '/login');
     $form = $crawler->selectButton('Log in')->form();
     $form['_username'] = $userName;
     $form['_password'] = $password;
     $this->client->submit($form);
     $this->assertEquals(302, $this->client->getResponse()->getStatusCode());
     $token = $this->client->getContainer()->get('security.token_storage')->getToken();
     $this->assertNull($token);
 }
开发者ID:open-orchestra,项目名称:open-orchestra,代码行数:16,代码来源:FormLoginTest.php

示例7: testAdd

 public function testAdd()
 {
     $crawler = $this->client->request('GET', '/member/add');
     $this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
     $this->assertEquals(1, $crawler->filter('div.app_member_add')->count());
     $this->assertEquals(1, $crawler->selectButton('add')->count());
     $button = $crawler->selectButton('add')->first();
     $form = $button->form(array('member[firstname]' => 'John', 'member[lastname]' => 'Doe', 'member[gender]' => 'm', 'member[birthday]' => '11/04/1980', 'member[birthplace]' => 'New-York City', 'member[address]' => 'Main street', 'member[zip]' => '01234', 'member[city]' => 'Washington D.C.'));
     $form['member[photo]']->upload(__DIR__ . '/../../photo.jpg');
     $this->client->submit($form);
     $this->assertTrue($this->client->getResponse()->isRedirect());
     $crawler = $this->client->followRedirect();
     $this->assertEquals(1, $crawler->filter('div.flash.success')->count());
 }
开发者ID:thomasage,项目名称:asso,代码行数:14,代码来源:MemberControllerTest.php

示例8: testEditProfile

 /**
  * test que les modifications d'un profil fonctionne
  */
 public function testEditProfile()
 {
     $crawler = $this->client->request('GET', '/profil');
     $form = $crawler->selectButton('Envoyer')->form();
     $form['application_sonata_user_profile[lastname]'] = 'Aaa';
     $form['application_sonata_user_profile[firstname]'] = 'Aaa';
     $form['application_sonata_user_profile[adresse]'] = '4 rue du bois';
     $form['application_sonata_user_profile[codePostal]'] = '28240';
     $form['application_sonata_user_profile[phone]'] = '0768298272';
     $form['application_sonata_user_profile[telephoneSecondaire]'] = '0768298272';
     $form['application_sonata_user_profile[caf]'] = '1234567';
     $form['application_sonata_user_profile[numeroIban]'] = '1234567891011121314151617181920AZERTYU';
     $crawler = $this->client->submit($form);
     $this->assertNotNull($crawler);
 }
开发者ID:WildCodeSchool,项目名称:projet-gesty,代码行数:18,代码来源:ProfileController___.php

示例9: testLogin

 /**
  * @dataProvider provideLoginData
  */
 public function testLogin(Client $client, $securedUrl, $login, $expectedMessage)
 {
     // client follow redirects
     $client->followRedirects();
     // go to secured page -> got login required
     $crawler = $client->request('GET', $securedUrl);
     $this->assertEquals(TrustedSsoController::LOGIN_REQUIRED_MESSAGE, $crawler->filter('#message')->text());
     // click link -> got login form
     $crawler = $client->click($crawler->filter('#url')->link());
     $this->assertEquals('login', $crawler->filter('form')->attr('id'));
     // fill form & submit -> got expected message
     $form = $crawler->filter('input[type=submit]')->form();
     $crawler = $client->submit($form, array('login[username]' => $login, 'login[password]' => $login));
     $this->assertEquals($expectedMessage, $crawler->filter('#message')->text());
     if (!$login === self::LOGIN_INVALID) {
         // check validation attributes
         $attrs = static::$kernel->getContainer()->get('security.context')->getToken()->getValidationAttributes();
         $this->assertEquals(array('attr1' => 'val1', 'attr2' => 'val2'), $attrs);
     }
     // logout -> got logout redirect
     $crawler = $client->request('GET', '/secured/logout');
     $this->assertEquals(TrustedSsoController::LOGOUT_REDIRECT_MESSAGE, $crawler->filter('#message')->text());
     // click link -> got logout done
     $crawler = $client->click($crawler->filter('#url')->link());
     $this->assertEquals(ServerController::LOGOUT_MESSAGE, $crawler->filter('#message')->text());
     // click link -> go to homepage
     $crawler = $client->click($crawler->filter('#url')->link());
     $this->assertEquals(TestController::HOME_MESSAGE, $crawler->filter('#message')->text());
 }
开发者ID:nicolasbui,项目名称:BeSimpleSsoAuthBundle,代码行数:32,代码来源:LoginTest.php

示例10: testValidationEmail

 public function testValidationEmail()
 {
     $crawler = $this->client->request('GET', '/contact');
     $form = $crawler->filter('form')->form();
     // L'email est vide
     $this->client->submit($form);
     $this->assertTrue($this->client->getResponse()->isClientError());
 }
开发者ID:apflieger,项目名称:zigotoo,代码行数:8,代码来源:ContactControllerTest.php

示例11: testRedirectRouteCreate

 public function testRedirectRouteCreate()
 {
     $crawler = $this->client->request('GET', '/admin/cmf/routing/redirectroute/create');
     $res = $this->client->getResponse();
     $this->assertEquals(200, $res->getStatusCode());
     $this->assertFrontendLinkNotPresent($crawler);
     $button = $crawler->selectButton('Create');
     $form = $button->form();
     $node = $form->getFormNode();
     $actionUrl = $node->getAttribute('action');
     $uniqId = substr(strchr($actionUrl, '='), 1);
     $form[$uniqId . '[parent]'] = '/test/routing';
     $form[$uniqId . '[name]'] = 'foo-test';
     $this->client->submit($form);
     $res = $this->client->getResponse();
     // If we have a 302 redirect, then all is well
     $this->assertEquals(302, $res->getStatusCode());
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:18,代码来源:RedirectRouteAdminTest.php

示例12: testCreationPageEleveur_NomInvalide

 public function testCreationPageEleveur_NomInvalide()
 {
     // connexion avec un nouvel user
     $this->testUtils->createUser();
     $pageEleveurForm = $this->client->request('GET', '/')->filter('form[name="creation-page-eleveur"]')->form();
     $pageEleveurForm['creation-page-eleveur[nom]'] = '--';
     $this->client->submit($pageEleveurForm);
     $this->assertEquals(Response::HTTP_NOT_ACCEPTABLE, $this->client->getResponse()->getStatusCode());
 }
开发者ID:apflieger,项目名称:zigotoo,代码行数:9,代码来源:DefaultControllerTest.php

示例13: makeDeleteAssertions

 /**
  * Make defaults deletion assertions.
  *
  * @param $url string the deletion url
  */
 protected function makeDeleteAssertions($url)
 {
     $crawler = $this->client->request('GET', $url);
     $res = $this->client->getResponse();
     $this->assertResponseSuccess($res);
     $button = $crawler->selectButton('Yes, delete');
     $form = $button->form();
     $this->client->submit($form);
     $res = $this->client->getResponse();
     // If we have a 302 redirect, then all is well
     $this->assertEquals(302, $res->getStatusCode(), $res->getContent());
 }
开发者ID:symfony-cmf,项目名称:block-bundle,代码行数:17,代码来源:AbstractBlockAdminTestCase.php

示例14: startRegistration

 private function startRegistration(\Symfony\Bundle\FrameworkBundle\Client $client, array $fields, $reset = true)
 {
     if ($reset) {
         $this->resetDatabase();
     }
     $crawler = $client->request('GET', '/');
     $buttonNode = $crawler->selectButton('Absenden');
     $form = $buttonNode->form();
     $form->disableValidation();
     $client->enableProfiler();
     $crawler = $client->submit($form, $fields);
     return $crawler;
 }
开发者ID:Galeria-Kaufhof,项目名称:goodbuy-metro,代码行数:13,代码来源:RegistrationTest.php

示例15: login

 /**
  * @param \Symfony\Bundle\FrameworkBundle\Client $client
  * @param bool                                   $asAdmin
  *
  * @return User
  */
 public function login($client, $asAdmin = false)
 {
     $testUser = $asAdmin ? $this->createLoginAdminUser() : $this->createLoginUser();
     $username = $testUser->getUsername();
     $passwort = $testUser->getPlainPassword();
     $this->saveInDb([$testUser]);
     $crawler = $client->request('GET', '/login');
     $client->followRedirects();
     $loginForm = $crawler->selectButton('_submit')->form();
     $loginForm['_username'] = $username;
     $loginForm['_password'] = $passwort;
     $crawler = $client->submit($loginForm);
     $this->assertFalse((bool) $crawler->filter('.form-signin')->count(), "Can't Login User.");
     return $testUser;
 }
开发者ID:TumTum,项目名称:TrolleyAgenda,代码行数:21,代码来源:webClientUserLoginTrait.php


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