當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。