Created
November 12, 2014 18:09
-
-
Save benglass/6eb6fe3f2b093785e936 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyTest | |
{ | |
public function testSomething() | |
{ | |
$crawler = $this->request('/foo'); | |
$form = $this->findFormByButtonText('Save'); | |
$data = array( | |
'name' => 'Foo' | |
); | |
$this->fillForm($form, $data); | |
// do something else like maybe add a file | |
$this->submitForm($form); | |
} | |
public function findFormByButtonText($crawler, $buttonText) | |
{ | |
$form = $button->form(); | |
$name = // find the form name from first input/select/textarea | |
return new Form($form->getNode(), $form->getUri(), $form->getMethod(), $name); | |
} | |
protected function findFormBySelector($crawler, $cssSelector) | |
{ | |
// example maybe use a css selector | |
} | |
} | |
class Form extends Form | |
{ | |
protected $crawler; | |
protected $namePrefix; | |
public function __construct(\DomElement $node, $currentUri, $method, $namePrefix = '') | |
{ | |
$this->namePrefix = $namePrefix; | |
parent::__construct($node, $currentUri, $method); | |
} | |
public function getNamePrefix() | |
{ | |
return $this->getNamePrefix(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment