本文整理汇总了PHP中PHPUnit_Framework_Assert::assertRegExp方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Assert::assertRegExp方法的具体用法?PHP PHPUnit_Framework_Assert::assertRegExp怎么用?PHP PHPUnit_Framework_Assert::assertRegExp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_Assert
的用法示例。
在下文中一共展示了PHPUnit_Framework_Assert::assertRegExp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertFakeEmailReceipt
/**
* @Then /^the latest email to ([^ ]+@[^ ]+) should contain "([^"]*)"$/
*/
public function assertFakeEmailReceipt($emailAddress, $pattern)
{
$regex = $this->fixStepArgument($pattern);
$inbox = $this->inboxFactory->getInbox($emailAddress);
$email = $inbox->getLatestEmail();
$body = $email->getBody();
\PHPUnit_Framework_Assert::assertRegExp("/{$regex}/", $body, sprintf('Did not find an email to %s which matched "%s". Found instead: %s – ', $emailAddress, $regex, $body));
}
示例2: processAssert
/**
* Assert that readiness check items are passed.
*
* @param SetupWizard $setupWizard
* @return void
*/
public function processAssert(SetupWizard $setupWizard)
{
\PHPUnit_Framework_Assert::assertContains(self::UPDATER_APPLICATION_MESSAGE, $setupWizard->getReadiness()->getUpdaterApplicationCheck(), 'Updater application check is incorrect.');
\PHPUnit_Framework_Assert::assertContains(self::CRON_SCRIPT_MESSAGE, $setupWizard->getReadiness()->getCronScriptCheck(), 'Cron scripts are incorrect.');
\PHPUnit_Framework_Assert::assertContains(self::DEPENDENCY_CHECK_MESSAGE, $setupWizard->getReadiness()->getDependencyCheck(), 'Dependency check is incorrect.');
\PHPUnit_Framework_Assert::assertContains(self::PHP_VERSION_MESSAGE, $setupWizard->getReadiness()->getPhpVersionCheck(), 'PHP version is incorrect.');
\PHPUnit_Framework_Assert::assertContains(self::PHP_SETTING_REGEXP, $setupWizard->getReadiness()->getSettingsCheck(), 'PHP settings check failed.');
\PHPUnit_Framework_Assert::assertRegExp(self::PHP_EXTENSIONS_REGEXP, $setupWizard->getReadiness()->getPhpExtensionsCheck(), 'PHP extensions missed.');
}
示例3: seeInLogs
public function seeInLogs(array $patterns)
{
foreach ($patterns as $pattern) {
$line = stream_get_line($this->logFile, 1024, "\n");
\PHPUnit_Framework_Assert::assertRegExp($pattern, $line);
}
$rest = stream_get_line($this->logFile, 1024, "\n");
$this->assertFalse($rest);
}
示例4: iSeeSearchResults
/**
* @Then I (should) see :total search result(s)
*/
public function iSeeSearchResults( $total )
{
$resultCountElement = $this->getXpath()->findXpath( "//div[@class = 'feedback']" );
EzAssertion::assertSingleElement( 'search feedback', $resultCountElement );
Assertion::assertRegExp(
"/Search for \"(.*)\" returned {$total} matches/",
$resultCountElement[0]->getText()
);
}
示例5: responseDataFieldContains
/**
* @Then the response data :field contains :value
*/
public function responseDataFieldContains($field, $value)
{
Assert::assertRegExp('/' . preg_quote($value) . '/i', $this->getResponseDataField($field));
}
示例6: assertRegExp
/**
* Asserts that a string matches a given regular expression.
*
* @param string $pattern
* @param string $string
* @param string $message
*/
function assertRegExp($pattern, $string, $message = '')
{
return PHPUnit_Framework_Assert::assertRegExp($pattern, $string, $message);
}
示例7: assertCommand
protected function assertCommand($command, $arguments, $info)
{
$method = $info['originalMethod'];
$result = $this->__call($method, $arguments);
if ($info['isBoolean']) {
if (!isset($info['negative']) || !$info['negative']) {
PHPUnit_Framework_Assert::assertTrue($result);
} else {
PHPUnit_Framework_Assert::assertFalse($result);
}
} else {
$expected = array_pop($arguments);
if (strpos($expected, 'exact:') === 0) {
$expected = substr($expected, strlen('exact:'));
if (!isset($info['negative']) || !$info['negative']) {
PHPUnit_Framework_Assert::assertEquals($expected, $result);
} else {
PHPUnit_Framework_Assert::assertNotEquals($expected, $result);
}
} else {
if (strpos($expected, 'regexp:') === 0) {
$expected = substr($expected, strlen('regexp:'));
} else {
if (strpos($expected, 'glob:') === 0) {
$expected = substr($expected, strlen('glob:'));
}
$expected = str_replace(array('*', '?'), array('.*', '.?'), $expected);
}
$expected = str_replace('/', '\\/', $expected);
if (!isset($info['negative']) || !$info['negative']) {
PHPUnit_Framework_Assert::assertRegExp('/' . $expected . '/', $result);
} else {
PHPUnit_Framework_Assert::assertNotRegExp('/' . $expected . '/', $result);
}
}
}
}
示例8: theResponseShouldContain
/**
* Checks that response body contains specific text.
*
* @param string $text
*
* @Then /^(?:the )?response should contain "([^"]*)"$/
*/
public function theResponseShouldContain($text)
{
$expectedRegexp = '/' . preg_quote($text) . '/i';
$actual = (string) $this->response->getBody();
Assertions::assertRegExp($expectedRegexp, $actual);
}
示例9: seeShellOutputMatches
public function seeShellOutputMatches($regex)
{
\PHPUnit_Framework_Assert::assertRegExp($regex, $this->output);
}
示例10: toMatchPattern
public function toMatchPattern($pattern)
{
if ($this->negate) {
a::assertNotRegExp($pattern, $this->actual);
} else {
a::assertRegExp($pattern, $this->actual);
}
}
示例11: matchesRegExp
public function matchesRegExp($expression)
{
Assert::assertRegExp($expression, $this->actual, $this->description);
return $this;
}
示例12: toMatch
public function toMatch($regex)
{
\PHPUnit_Framework_Assert::assertRegExp($regex, $this->actual);
}
示例13: theResponseShouldContain
/**
* Checks that response body contains specific text.
*
* @param string $text
*
* @Then /^(?:the )?response should contain "([^"]*)"$/
*/
public function theResponseShouldContain($text)
{
\PHPUnit_Framework_Assert::assertRegExp('/' . preg_quote($text) . '/', $this->browser->getLastResponse()->getContent());
}
示例14: assertRevisionSummary
/**
* Asserts that the revision with the given ID has a summary matching $regex
*
* @param string|string[] $regex The regex to match, or an array to build a regex from
* @param int $revid
* @param string $message
*/
public function assertRevisionSummary($regex, $revid, $message = '')
{
if (is_array($regex)) {
$r = '';
foreach ($regex as $s) {
if (strlen($r) > 0) {
$r .= '.*';
}
$r .= preg_quote($s, '!');
}
$regex = "!{$r}!";
}
$entry = $this->mockRepository->getLogEntry($revid);
Assert::assertNotNull($entry, "revision not found: {$revid}");
Assert::assertRegExp($regex, $entry['summary'], $message);
}
示例15: testGetAccessToken
public function testGetAccessToken()
{
$response = $this->getMockBuilder('Widop\\HttpAdapter\\HttpResponse')->disableOriginalConstructor()->getMock();
$response->expects($this->once())->method('getBody')->will($this->returnValue('oauth_token=token_key&oauth_token_secret=token_secret'));
$this->httpAdapter->expects($this->once())->method('postContent')->with($this->equalTo('https://api.twitter.com/oauth/access_token'), $this->callback(function ($headers) {
try {
\PHPUnit_Framework_Assert::assertArrayHasKey('Authorization', $headers);
\PHPUnit_Framework_Assert::assertRegExp('#OAuth oauth_verifier="oauth_verifier", oauth_version="1.0", oauth_consumer_key="consumer_key", oauth_signature_method="signature-name", oauth_token="token_key", oauth_signature="signature", oauth_nonce="(.*)", oauth_timestamp="(.*)"#', $headers['Authorization']);
return true;
} catch (\Exception $e) {
return false;
}
}))->will($this->returnValue($response));
$accessToken = $this->oauth->getAccessToken(new OAuthToken('token_key', 'token_secret'), 'oauth_verifier');
$this->assertInstanceOf('Widop\\Twitter\\OAuth\\Token\\OAuthToken', $accessToken);
$this->assertSame('token_key', $accessToken->getKey());
$this->assertSame('token_secret', $accessToken->getSecret());
}