本文整理汇总了PHP中PHPUnit_Framework_Assert::assertFileExists方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Assert::assertFileExists方法的具体用法?PHP PHPUnit_Framework_Assert::assertFileExists怎么用?PHP PHPUnit_Framework_Assert::assertFileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_Assert
的用法示例。
在下文中一共展示了PHPUnit_Framework_Assert::assertFileExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fileShouldContain
/**
* @Then :file file should contain:
*
* @param string $file
* @param PyStringNode $strings
*/
public function fileShouldContain($file, PyStringNode $strings)
{
PHPUnit::assertFileExists($file);
$contents = file_get_contents($file);
$strings = $strings->getStrings();
array_walk($strings, function ($string) use($contents) {
PHPUnit::assertContains($string, $contents);
});
}
示例2: fileShouldContain
/**
* Checks whether specified file exists and contains specified string.
*
* @Then /^"([^"]*)" file should contain:$/
*
* @param string $path file path
* @param PyStringNode $text file content
*/
public function fileShouldContain($path, PyStringNode $text)
{
$path = $this->workingDir . '/' . $path;
PHPUnit_Framework_Assert::assertFileExists($path);
$fileContent = trim(file_get_contents($path));
// Normalize the line endings in the output
if ("\n" !== PHP_EOL) {
$fileContent = str_replace(PHP_EOL, "\n", $fileContent);
}
PHPUnit_Framework_Assert::assertEquals($this->getExpectedOutput($text), $fileContent);
}
示例3: toExist
public function toExist()
{
if ($this->negate) {
a::assertFileNotExists($this->actual);
} else {
a::assertFileExists($this->actual);
}
}
示例4: shouldContain
/**
* Checks whether specified file exists and contains specified string.
*
* @Then /^"([^"]*)" should contain( the string|):$/
*/
public function shouldContain($path, $subString, PyStringNode $string)
{
$subString = !empty($subString);
if ($path[0] == '~') {
$path = $this->homeDir . ltrim($path, '~');
} else {
$path = $this->workingDir . '/' . $path;
}
PHPUnit_Framework_Assert::assertFileExists($path);
$fileContent = trim(file_get_contents($path));
// Normalize the line endings in the output
if ("\n" !== PHP_EOL) {
$fileContent = str_replace(PHP_EOL, "\n", $fileContent);
}
// Trim trailing whitespace. It usually messes things up.
$fileContent = trim(preg_replace("/ +\$/m", '', $fileContent));
if ($subString) {
PHPUnit_Framework_Assert::assertContains((string) $string, $fileContent);
} else {
PHPUnit_Framework_Assert::assertEquals((string) $string, $fileContent);
}
}
示例5: exists
public function exists()
{
if (!$this->isFileExpectation) {
throw new \Exception('exists() expectation should be called with expect_file()');
}
a::assertFileExists($this->actual, $this->description);
}
示例6: theFileShouldExists
/**
* @Then The :key file should exists
*/
public function theFileShouldExists($key)
{
\PHPUnit_Framework_Assert::assertFileExists($this->result[$key]);
unlink($this->result[$key]);
}
示例7: assertFileContents
/**
* @Then :name file should contain:
*/
public function assertFileContents($name, PyStringNode $contents)
{
PHPUnit_Framework_Assert::assertFileExists($name);
PHPUnit_Framework_Assert::assertContains($contents->getRaw(), file_get_contents($name));
}
示例8: assertFileExists
/**
* Checks if file exists
*
* @param string $filename
* @param string $message
*/
protected function assertFileExists($filename, $message = '')
{
\PHPUnit_Framework_Assert::assertFileExists($filename, $message);
}
示例9: theJunitFileShouldContain
/**
* @Then /^the junit file "([^"]*)" should contain:$/
*/
public function theJunitFileShouldContain($file, PyStringNode $text)
{
PHPUnit_Framework_Assert::assertFileExists($file);
// replace random time ...
$contents = preg_replace('@time="[0-9.]*"@', 'time="XXX"', file_get_contents($file));
// replace random path
$contents = preg_replace('@[0-9a-zA-Z]{32}@', 'XXX', $contents);
// fix random path in exception ...
$contents = preg_replace('@<!\\[CDATA\\[.*\\]\\]>@s', '<![CDATA[XXX]]>', $contents);
PHPUnit_Framework_Assert::assertEquals($contents, (string) $text);
}
示例10: assertVfsFileExists
/**
* Asserts that a vfs file exists.
*
* @param $filename
* @param string $message
*/
public function assertVfsFileExists($filename, $message = '')
{
PHPUnit::assertFileExists($this->getPath($filename), $message);
}
示例11: theFileShouldExistInProject
/**
* @Then the file :file should exist in :project
*/
public function theFileShouldExistInProject($file, $project)
{
$path = sprintf('%s/%s/%s', $this->cwd, $project, $file);
Assert::assertFileExists($path);
}
示例12: seeFileFound
/**
* Checks if file exists in path.
* Opens a file when it's exists
*
* ``` php
* <?php
* $I->seeFileFound('UserModel.php','app/models');
* ?>
* ```
*
* @param $filename
* @param string $path
*/
public function seeFileFound($filename, $path = '')
{
if (file_exists($filename) and !$path) {
$this->openFile($filename);
$this->filepath = $filename;
$this->debug($filename);
\PHPUnit_Framework_Assert::assertFileExists($path . $filename);
return;
}
$path = $this->absolutizePath($path);
$this->debug($path);
if (!file_exists($path)) {
\PHPUnit_Framework_Assert::fail("Directory does not exist: {$path}");
}
$files = Finder::create()->files()->name($filename)->in($path);
foreach ($files as $file) {
$file = $file->getRealPath();
$this->openFile($file);
$this->filepath = $file;
$this->debug($file);
\PHPUnit_Framework_Assert::assertFileExists($file);
return;
}
\Codeception\Util\Debug::pause();
$this->fail("{$filename} in {$path}");
}
示例13: fileXmlShouldBeLike
/**
* Checks whether specified content and structure of the xml is correct without worrying about layout.
*
* @Then /^"([^"]*)" file xml should be like:$/
*
* @param string $path file path
* @param PyStringNode $text file content
*/
public function fileXmlShouldBeLike($path, PyStringNode $text)
{
$path = $this->workingDir . '/' . $path;
PHPUnit_Framework_Assert::assertFileExists($path);
$fileContent = trim(file_get_contents($path));
$dom = new DOMDocument();
$dom->loadXML($text);
$dom->formatOutput = true;
PHPUnit_Framework_Assert::assertEquals(trim($dom->saveXML(null, LIBXML_NOEMPTYTAG)), $fileContent);
}
示例14: shouldExist
public function shouldExist()
{
Assert::assertFileExists($this->it);
}
示例15: toExist
/**
* Expect that a file exists.
*
* @param string $message
*
* @return Expect
*/
public function toExist($message = '')
{
Assert::assertFileExists($this->value, $message);
return $this;
}