/** * @Then I should see: */ public function iShouldSee(PyStringNode $content) { $displayArray = explode("\n", $this->tester->getDisplay()); array_walk($displayArray, function (&$line) { $line = rtrim($line); }); expect($displayArray)->shouldBeLike($content->getStrings()); }
/** * @Then /^the console output should have lines ending in:$/ */ public function theConsoleOutputShouldHaveLinesEndingIn(PyStringNode $string) { $stdOutLines = explode(PHP_EOL, $this->lastBehatStdOut); $expectedLines = $string->getStrings(); \PHPUnit_Framework_Assert::assertCount(count($expectedLines), $stdOutLines); foreach ($stdOutLines as $idx => $stdOutLine) { $suffix = isset($expectedLines[$idx]) ? $expectedLines[$idx] : '(NONE)'; $constraint = \PHPUnit_Framework_Assert::stringEndsWith($suffix); $constraint->evaluate($stdOutLine); } }
/** * Expect until all of the named events have been fired. * * @Then I expect the following events: */ public function iExpectTheFollowingEvents(PyStringNode $eventNames) { $this->waitForAuraEvents($eventNames->getStrings(), 5000); }
/** * @Given output should not be: */ public function outputShouldNotBe(PyStringNode $string) { $expected = $string->getStrings(); $check = false; foreach ($this->output as $index => $line) { if ($line !== $expected[$index]) { $check = true; break; } } if ($check === false) { throw new \Exception("Output should not be"); } }
/** * @Given /^the output should contain:$/ */ public function theOutputShouldContain(PyStringNode $string) { foreach ($string->getStrings() as $line) { \PHPUnit_Framework_Assert::assertContains($line, $this->getOutput()); } }
public function testGetStrings() { $str = new PyStringNode(array('line1', 'line2', 'line3'), 0); $this->assertEquals(array('line1', 'line2', 'line3'), $str->getStrings()); }
/** * @Then the headers contain */ public function theHeadersContain(PyStringNode $string) { $response = $this->getClient()->getResponse(); foreach ($string->getStrings() as $header) { list($name, $value) = preg_split('/\\s*:\\s*/', $header, 2); \assertTrue($response->headers->has($name)); \assertEquals($value, $response->headers->get($name)); } }
/** * @Then I should get: */ public function iShouldGet(PyStringNode $string) { assertEquals($this->outputLines, $string->getStrings()); }
/** * @param PyStringNode $options * * @return array */ private function parseOptions(PyStringNode $options) { $return = array(); foreach ($options->getStrings() as $option) { if (preg_match('/(?P<option>\\-\\-[a-zA-Z0-9\\-]*)((\\=|\\s)(?P<value>[^\\n\\s]*))?/', $option, $matches)) { $return[$matches['option']] = isset($matches['value']) ? $matches['value'] : true; } if (preg_match('/(?P<option>\\-[a-zA-Z0-9\\-]*) (?P<value>[^\\n\\s]*)?/', $option, $matches)) { $return[$matches['option']] = isset($matches['value']) ? $matches['value'] : true; } } return $return; }