Esempio n. 1
0
 /**
  * Ensures that addDirectory() returns expected value
  *
  * @return void
  */
 public function testAddDirectory()
 {
     $validator = new File\Exists('temp');
     $validator->addDirectory('gif');
     $this->assertEquals('temp,gif', $validator->getDirectory());
     $this->assertEquals(array('temp', 'gif'), $validator->getDirectory(true));
     $validator->addDirectory('jpg, to');
     $this->assertEquals('temp,gif,jpg,to', $validator->getDirectory());
     $this->assertEquals(array('temp', 'gif', 'jpg', 'to'), $validator->getDirectory(true));
     $validator->addDirectory(array('zip', 'ti'));
     $this->assertEquals('temp,gif,jpg,to,zip,ti', $validator->getDirectory());
     $this->assertEquals(array('temp', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getDirectory(true));
     $validator->addDirectory('');
     $this->assertEquals('temp,gif,jpg,to,zip,ti', $validator->getDirectory());
     $this->assertEquals(array('temp', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getDirectory(true));
 }
Esempio n. 2
0
 /**
  * @group ZF-11258
  */
 public function testZF11258()
 {
     $validator = new File\Exists(__DIR__);
     $this->assertFalse($validator->isValid('nofile.mo'));
     $this->assertTrue(array_key_exists('fileExistsDoesNotExist', $validator->getMessages()));
     $this->assertContains("'nofile.mo'", current($validator->getMessages()));
 }
Esempio n. 3
0
<?php

// @codingStandardsIgnoreFile
use Zend\Validator\Callback as CallbackValidator;
use Zend\Validator\File\Exists as FileExistsValidator;
use Zend\Validator\InArray as InArrayValidator;
use Zend\Validator\Regex as RegexValidator;
use ZF\Console\Filter\Explode as ExplodeFilter;
$fileExists = new FileExistsValidator();
$minorVersionValidator = new CallbackValidator(function ($value) {
    return preg_match('/^(0|[1-9][0-9]*)\\.[0-9]+$/', $value);
});
$semanticVersionValidator = new CallbackValidator(function ($value) {
    return preg_match('/^(0|[1-9][0-9]*)\\.[0-9]+\\.[0-9]+$/', $value);
});
return [['name' => 'lts-release', 'route' => '<version> [--exclude=] [--basePath=] [--verbose|-v]', 'description' => 'Tag a new LTS maintenance release of all components. This command will check out a release branch based off the latest maintenance release matching the provided minor release version and tag the new release with no changes. USE THIS ONLY FOR TAGGING COMPONENTS WITH NO CHANGES.', 'short_description' => 'Tag a new LTS maintenance release of all components.', 'options_descriptions' => ['<version>' => 'Minor version against which to create new release.', '--exclude' => 'Comma-separated list of components to exclude from the release; typically those that had changes.', '--basePath' => 'Path to component checkouts; if not specified, assumed to be the current working directory.', '--verbose' => 'Verbosity'], 'defaults' => ['basePath' => realpath(getcwd()), 'exclude' => []], 'filters' => ['exclude' => new ExplodeFilter(',')], 'validators' => ['version' => $minorVersionValidator]], ['name' => 'lts-components', 'route' => '', 'description' => 'List LTS components, one per line. This can be useful when looping in console scripts: for COMPONENT in $(maintainer.php components | grep "^zend-");do done', 'short_description' => 'List LTS components, one per line.'], ['name' => 'lts-patch', 'route' => '--patchfile= --target= --component=', 'description' => 'Rewrite a patch made against a component so that it may be applied against the monolithic ZF2 repository.', 'short_description' => 'Rewrite a component patch so it may be applied against the ZF2 repo.', 'options_descriptions' => ['--patchfile' => 'Path to the component patchfile to use as the source patch.', '--target' => 'Filename to which to write the rewritten patchfile.', '--component' => 'Name of the component (e.g., zend-view, zend-inputfilter, etc) against which the patch was made.'], 'validators' => ['patchfile' => new FileExistsValidator(), 'target' => new CallbackValidator(function ($value) {
    return is_dir(dirname($value));
}), 'component' => new RegexValidator('/^zend-[a-z-]+$/')], 'handler' => 'ZF\\Maintainer\\RewritePatch'], ['name' => 'lts-stage', 'route' => '<version> --patchfile= [--verbose|-v]', 'description' => 'Checkout a temporary branch based on the last release of the given minor version, and apply the patchfile(s) provided.

If you wish to apply multiple patches, specify them to the --patchfile argument
as a comma-delimited list:

    $ maintainer.php lts-stage 2.4 --patchfile=0001.patch,0002.patch,0003.patch

Patchfiles are applied in the order provided.
', 'short_description' => 'Stage a new LTS release by applying the given patchfile(s).', 'options_descriptions' => ['<version>' => 'Minor version against which to create new release.', '--patchfile' => 'Path to the patchfile to apply; specify multiple patchfiles by using a comma-delimiter.', '--verbose' => 'Verbosity'], 'filters' => ['patchfile' => new ExplodeFilter(',')], 'validators' => ['patchfile' => new CallbackValidator(function ($value) use($fileExists) {
    if (is_string($value)) {
        return $fileExists->isValid($value);
    }
    foreach ($value as $filename) {
        if (!$fileExists->isValid($filename)) {
Esempio n. 4
0
 public function testEmptyFileArrayShouldReturnFalse()
 {
     $validator = new File\Exists();
     $this->assertFalse($validator->isValid(''));
     $this->assertArrayHasKey(File\Exists::DOES_NOT_EXIST, $validator->getMessages());
     $filesArray = array('name' => '', 'size' => 0, 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, 'type' => '');
     $this->assertFalse($validator->isValid($filesArray));
     $this->assertArrayHasKey(File\Exists::DOES_NOT_EXIST, $validator->getMessages());
 }