public function testTextcleaner() { $textcleaner = new Textcleaner(dirname(__FILE__) . '/images/image.jpg'); $textcleaner->setOutputImage(dirname(__FILE__) . '/out.jpg'); $textcleaner->execute(); assertFileExists(dirname(__FILE__) . '/out.jpg'); }
/** * @Given /^Unpack files to the same directory:$/ */ public function unpackFilesToTheSameDirectory(PyStringNode $string) { $expectedFiles = $string->getLines(); $this->pagesDir = $this->package->unpack($expectedFiles); assertFileExists($this->pagesDir); chdir($this->pagesDir); $foundFiles = array_flip(glob('*.html')); assertCount(count($expectedFiles), $foundFiles); foreach ($expectedFiles as $file) { assertArrayHasKey($file, $foundFiles); } }
/** * Checks whether specified file exists and contains specified string. * * @Given /^"([^"]*)" file should contain:$/ * * @param string $path file path * @param Behat\Gherkin\Node\PyStringNode $text file content */ public function fileShouldContain($path, PyStringNode $text) { try { assertFileExists($path); assertEquals((string) $text, trim(file_get_contents($path))); } catch (Exception $e) { $diff = PHPUnit_Framework_TestFailure::exceptionToString($e); throw new Exception($diff, $e->getCode(), $e); } }
/** * Checks that a file or folder exists in the webroot. * Example: There should be a file "assets/Uploads/test.jpg" * * @Then /^there should be a (?<type>(file|folder) )"(?<path>[^"]*)"/ */ public function stepThereShouldBeAFileOrFolder($type, $path) { assertFileExists($this->joinPaths(BASE_PATH, $path)); }
public function test_it_can_touch_a_path() { $this->MediaPaths->touch('some/file.txt'); assertFileExists('vfs://basePath/some/file.txt'); }
/** * Assert the file structure exists in the test filesystem. * * @param array $structure * @param string $prefix */ protected function seeGenerated(array $structure, $prefix = '.') { foreach ($this->parseStructure($structure) as $name => $value) { if (is_array($value)) { $this->seeGenerated($value, "{$prefix}/{$name}"); } else { $url = vfsStream::url("test/build/{$prefix}/{$name}"); assertFileExists($url); if ($value) { assertStringMatchesFormat($value, file_get_contents($url)); } } } }
$steps->When('/^I run "behat ([^"]*)"$/', function ($world, $command) { $php = 0 === mb_strpos(BEHAT_PHP_BIN_PATH, '/usr/bin/env') ? BEHAT_PHP_BIN_PATH : escapeshellarg(BEHAT_PHP_BIN_PATH); $command = strtr($command, array('\'' => '"')); exec($php . ' ' . escapeshellarg(BEHAT_BIN_PATH) . ' --no-time --no-colors ' . $command, $output, $return); $world->command = $command; $world->output = trim(implode("\n", $output)); $world->return = $return; }); $steps->Given('/^I am in the "([^"]*)" path$/', function ($world, $path) { if (!file_exists($path)) { mkdir($path, 0777, true); chdir($path); } }); $steps->Then('/^file "([^"]*)" should exist$/', function ($world, $path) { assertFileExists(getcwd() . DIRECTORY_SEPARATOR . $path); }); $steps->Then('/^it should (fail|pass) with:$/', function ($world, $success, $text) { if ('fail' === $success) { assertNotEquals(0, $world->return); } else { assertEquals(0, $world->return); } // windows path fix if ('/' !== DIRECTORY_SEPARATOR) { $text = preg_replace_callback('/ features\\/[^\\n ]+/', function ($matches) { return str_replace('/', DIRECTORY_SEPARATOR, $matches[0]); }, (string) $text); $text = preg_replace_callback('/\\<span class\\="path"\\>features\\/[^\\<]+/', function ($matches) { return str_replace('/', DIRECTORY_SEPARATOR, $matches[0]); }, (string) $text);
/** * @Then Assert the file :arg1 exists local * @param $filename */ public function assertFileExists($filename) { assertFileExists($filename, sprintf("Asserting the file [%s] exists local", $filename)); }
public function test_it_renames() { $this->Filesystem = new Filesystem(); $this->Filesystem->rename('vfs://baseFilePath/some_file.txt', 'vfs://baseFilePath/some_renamed_file.txt'); assertFileExists('vfs://baseFilePath/some_renamed_file.txt'); }
public function test_it_makes_thumbnail_images() { $image = $this->Images->makeThumbnailImage('vfs://baseImagePath/test.png', $this->testImageFile); assertEquals(200, $image->getImageWidth()); assertFileExists($this->testImageFile); }