Update test setup to use Share 2.0 #663

This commit is contained in:
Olivier Paroz 2016-06-11 02:09:42 +02:00
Родитель 42500a942d
Коммит db0d2b92a5
20 изменённых файлов: 561 добавлений и 262 удалений

Просмотреть файл

@ -98,7 +98,7 @@ before_script:
script:
# Test lint
- php vendor/bin/parallel-lint --exclude travis --exclude vendor . vendor/composer vendor/symfony/yaml vendor/autoload.php
- php vendor/bin/parallel-lint --exclude vendor/composer/autoload_static.php --exclude travis --exclude vendor . vendor/composer vendor/symfony/yaml vendor/autoload.php
# Acceptance tests, using Firefox, without code coverage
- php vendor/bin/codecept run acceptance --env firefox

Просмотреть файл

@ -27,9 +27,9 @@
"symfony/yaml": "~2.6"
},
"require-dev": {
"guzzlehttp/guzzle": "^5.0|^6.0",
"phpunit/phpunit": "^4.0|^5.1",
"codeception/codeception": "2.1.*",
"guzzlehttp/guzzle": "^5.0|^6.2",
"phpunit/phpunit": "^4.0|^5.4",
"codeception/codeception": "2.2.*",
"codeception/phpbuiltinserver": "*",
"composer-plugin-api": "^1.0",
"codeception/c3": "2.*",

441
composer.lock сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -108,6 +108,8 @@ class DataSetup extends \Codeception\Module {
private $server;
/** @var IUserManager */
private $userManager;
/** @var Share\IManager */
private $shareManager;
/** @var IRootFolder */
private $rootFolder;
/** @var array */
@ -128,6 +130,7 @@ class DataSetup extends \Codeception\Module {
$this->server = $this->container->getServer();
$this->rootFolder = $this->server->getRootFolder();
$this->userManager = $this->server->getUserManager();
$this->shareManager = $this->server->getShareManager();
/**
* Logging hooks are missing at the moment, so we need to disable encryption
@ -395,6 +398,7 @@ class DataSetup extends \Codeception\Module {
* @return bool|string
*/
protected function createShare($nodeType, $shareWith = null) {
$share = $this->shareManager->newShare();
/**
* Pick the file or the folder
*/
@ -403,12 +407,16 @@ class DataSetup extends \Codeception\Module {
} else {
$sharedNode = $this->sharedFolder;
}
$fileInfo = $sharedNode->getFileInfo();
$share->setNode($sharedNode)
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setSharedBy($this->sharerUserId);
/**
* Decide which type of share it is
*/
$shareType = \OCP\Share::SHARE_TYPE_USER;
if ($shareWith === null) {
// We need to make sure sharing via link is enabled
$this->server->getConfig()
@ -416,19 +424,19 @@ class DataSetup extends \Codeception\Module {
// Only password protect the folders
if ($nodeType === 'folder') {
$shareWith = $this->passwordForFolderShare;
$share->setPassword($this->passwordForFolderShare);
}
$shareType = \OCP\Share::SHARE_TYPE_LINK;
} else {
$share->setSharedWith($shareWith);
}
/**
* Share and generate the token if it's a public share
*/
$share->setShareType($shareType);
return Share::shareItem(
$nodeType, $fileInfo['fileid'], $shareType, $shareWith,
\OCP\Constants::PERMISSION_ALL
);
$this->shareManager->createShare($share);
return $share->getToken();
}
}

Просмотреть файл

@ -57,7 +57,7 @@ class Login {
public function confirmLogin() {
$I = $this->acceptanceTester;
$I->seeCurrentUrlEquals(FilesPage::$URL);
$I->seeInCurrentUrl(FilesPage::$URL);
$I->seeElement(['css' => FilesPage::$contentDiv]);
}
}

Просмотреть файл

@ -182,10 +182,11 @@ class FilesControllerTest extends \Test\GalleryUnitTest {
'design' => [],
];
$folder = $this->mockFolder(
'home::user', $folderId, $files, true, false, null, '', false, $folderIsShared,
$folderEtag, 4096, 'some/path', null, $folderPermissions
);
$folderData = ['home::user', $folderId, $files, true, false, null, '', false, $folderIsShared,
$folderEtag, 4096, 'some/path', null, $folderPermissions];
$folder = call_user_func_array([$this,'mockFolder'], $folderData);
$folder2 = call_user_func_array([$this, 'mockFolder'], $folderData);
return [
[
@ -199,7 +200,7 @@ class FilesControllerTest extends \Test\GalleryUnitTest {
]
],
[
$location, $folderPathFromRoot, $folder, $albumConfig, $files, $albums, $folderEtag,
$location, $folderPathFromRoot, $folder2, $albumConfig, $files, $albums, $folderEtag,
[
'files' => [],
'albums' => [],

Просмотреть файл

@ -225,8 +225,17 @@ class SearchMediaServiceTest extends \Test\GalleryUnitTest {
[$folder5, $folder5Path],
];
// 1 standard folder, 1 external share (ignored) and 3 files
$folder1a = $this->mockFolder(
'home::user', 545454,
[
$this->mockJpgFile(11111),
$this->mockJpgFile(22222),
$this->mockJpgFile(33333)
],
$isReadable, $mounted, $mount, $query, $queryResult
);
$config5 = [
$folder1,
$folder1a,
$folder6,
$this->mockJpgFile(77777),
$this->mockJpgFile(88888),
@ -239,12 +248,21 @@ class SearchMediaServiceTest extends \Test\GalleryUnitTest {
);
$map5 = [
[$topFolder5, ''],
[$folder1, $folder1Path],
[$folder1a, $folder1Path],
[$folder6, $folder6Path],
];
// 1 standard folder (3), 1 deep folder and 3 files
$folder1b = $this->mockFolder(
'home::user', 545454,
[
$this->mockJpgFile(11111),
$this->mockJpgFile(22222),
$this->mockJpgFile(33333)
],
$isReadable, $mounted, $mount, $query, $queryResult
);
$config6 = [
$folder1,
$folder1b,
$folder7,
$this->mockJpgFile(77777),
$this->mockJpgFile(88888),
@ -256,7 +274,7 @@ class SearchMediaServiceTest extends \Test\GalleryUnitTest {
);
$map6 = [
[$topFolder6, ''],
[$folder1, $folder1Path],
[$folder1b, $folder1Path],
[$folder7, $folder7Path],
];
@ -331,6 +349,11 @@ class SearchMediaServiceTest extends \Test\GalleryUnitTest {
$file1Data['etag'], $file1Data['size'], $file1Data['sharedwithuser'], null,
$file1Data['permissions']
);
$file1a = $this->mockJpgFile(
$file1Data['nodeid'], 'home::user', $isReadable, $file1Data['path'],
$file1Data['etag'], $file1Data['size'], $file1Data['sharedwithuser'], null,
$file1Data['permissions']
);
$ownerUid = 909090;
$ownerName = 'San Akinamoura';
@ -400,7 +423,7 @@ class SearchMediaServiceTest extends \Test\GalleryUnitTest {
'home::user',
$topFolder1Data['nodeid'],
[
$file1,
$file1a,
$albumIgnored
],
$isReadable, $mounted, $mount, $query, $queryResult, $topFolder1Data['sharedwithuser'],
@ -415,7 +438,7 @@ class SearchMediaServiceTest extends \Test\GalleryUnitTest {
[$album1, $album1Data['path']],
];
$map2 = [
[$file1, $file1Data['path']],
[$file1a, $file1Data['path']],
[$topFolder2, $topFolder2Data['path']],
];

21
vendor/composer/LICENSE поставляемый Normal file
Просмотреть файл

@ -0,0 +1,21 @@
Copyright (c) 2016 Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

29
vendor/composer/autoload_real.php поставляемый
Просмотреть файл

@ -23,19 +23,26 @@ class ComposerAutoloaderInit3cfd72445e0ad28db5332442bcda1e66
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit3cfd72445e0ad28db5332442bcda1e66', 'loadClassLoader'));
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
call_user_func(\Composer\Autoload\ComposerStaticInit3cfd72445e0ad28db5332442bcda1e66::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);

45
vendor/composer/autoload_static.php поставляемый Normal file
Просмотреть файл

@ -0,0 +1,45 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit3cfd72445e0ad28db5332442bcda1e66
{
public static $prefixLengthsPsr4 = array (
'S' =>
array (
'Symfony\\Component\\Yaml\\' => 23,
),
);
public static $prefixDirsPsr4 = array (
'Symfony\\Component\\Yaml\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/yaml',
),
);
public static $classMap = array (
'Symfony\\Component\\Yaml\\Dumper' => __DIR__ . '/..' . '/symfony/yaml/Dumper.php',
'Symfony\\Component\\Yaml\\Escaper' => __DIR__ . '/..' . '/symfony/yaml/Escaper.php',
'Symfony\\Component\\Yaml\\Exception\\DumpException' => __DIR__ . '/..' . '/symfony/yaml/Exception/DumpException.php',
'Symfony\\Component\\Yaml\\Exception\\ExceptionInterface' => __DIR__ . '/..' . '/symfony/yaml/Exception/ExceptionInterface.php',
'Symfony\\Component\\Yaml\\Exception\\ParseException' => __DIR__ . '/..' . '/symfony/yaml/Exception/ParseException.php',
'Symfony\\Component\\Yaml\\Exception\\RuntimeException' => __DIR__ . '/..' . '/symfony/yaml/Exception/RuntimeException.php',
'Symfony\\Component\\Yaml\\Inline' => __DIR__ . '/..' . '/symfony/yaml/Inline.php',
'Symfony\\Component\\Yaml\\Parser' => __DIR__ . '/..' . '/symfony/yaml/Parser.php',
'Symfony\\Component\\Yaml\\Unescaper' => __DIR__ . '/..' . '/symfony/yaml/Unescaper.php',
'Symfony\\Component\\Yaml\\Yaml' => __DIR__ . '/..' . '/symfony/yaml/Yaml.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit3cfd72445e0ad28db5332442bcda1e66::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit3cfd72445e0ad28db5332442bcda1e66::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit3cfd72445e0ad28db5332442bcda1e66::$classMap;
}, null, ClassLoader::class);
}
}

12
vendor/composer/installed.json поставляемый
Просмотреть файл

@ -1,23 +1,23 @@
[
{
"name": "symfony/yaml",
"version": "v2.8.3",
"version_normalized": "2.8.3.0",
"version": "v2.8.7",
"version_normalized": "2.8.7.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "2a4ee40acb880c56f29fb1b8886e7ffe94f3b995"
"reference": "815fabf3f48c7d1df345a69d1ad1a88f59757b34"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/2a4ee40acb880c56f29fb1b8886e7ffe94f3b995",
"reference": "2a4ee40acb880c56f29fb1b8886e7ffe94f3b995",
"url": "https://api.github.com/repos/symfony/yaml/zipball/815fabf3f48c7d1df345a69d1ad1a88f59757b34",
"reference": "815fabf3f48c7d1df345a69d1ad1a88f59757b34",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"time": "2016-02-23 07:41:20",
"time": "2016-06-06 11:11:27",
"type": "library",
"extra": {
"branch-alias": {

6
vendor/symfony/yaml/Dumper.php поставляемый
Просмотреть файл

@ -32,6 +32,10 @@ class Dumper
*/
public function setIndentation($num)
{
if ($num < 1) {
throw new \InvalidArgumentException('The indentation must be greater than zero.');
}
$this->indentation = (int) $num;
}
@ -54,7 +58,7 @@ class Dumper
if ($inline <= 0 || !is_array($input) || empty($input)) {
$output .= $prefix.Inline::dump($input, $exceptionOnInvalidType, $objectSupport);
} else {
$isAHash = array_keys($input) !== range(0, count($input) - 1);
$isAHash = Inline::isHash($input);
foreach ($input as $key => $value) {
$willBeInlined = $inline - 1 <= 0 || !is_array($value) || empty($value);

30
vendor/symfony/yaml/Inline.php поставляемый
Просмотреть файл

@ -157,6 +157,28 @@ class Inline
}
}
/**
* Check if given array is hash or just normal indexed array.
*
* @internal
*
* @param array $value The PHP array to check
*
* @return bool true if value is hash array, false otherwise
*/
public static function isHash(array $value)
{
$expectedKey = 0;
foreach ($value as $key => $val) {
if ($key !== $expectedKey++) {
return true;
}
}
return false;
}
/**
* Dumps a PHP array to a YAML string.
*
@ -169,11 +191,7 @@ class Inline
private static function dumpArray($value, $exceptionOnInvalidType, $objectSupport)
{
// array
$keys = array_keys($value);
$keysCount = count($keys);
if ((1 === $keysCount && '0' == $keys[0])
|| ($keysCount > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) === $keysCount * ($keysCount - 1) / 2)
) {
if ($value && !self::isHash($value)) {
$output = array();
foreach ($value as $val) {
$output[] = self::dump($val, $exceptionOnInvalidType, $objectSupport);
@ -182,7 +200,7 @@ class Inline
return sprintf('[%s]', implode(', ', $output));
}
// mapping
// hash
$output = array();
foreach ($value as $key => $val) {
$output[] = sprintf('%s: %s', self::dump($key, $exceptionOnInvalidType, $objectSupport), self::dump($val, $exceptionOnInvalidType, $objectSupport));

36
vendor/symfony/yaml/Parser.php поставляемый
Просмотреть файл

@ -25,6 +25,7 @@ class Parser
const FOLDED_SCALAR_PATTERN = self::BLOCK_SCALAR_HEADER_PATTERN;
private $offset = 0;
private $totalNumberOfLines;
private $lines = array();
private $currentLineNb = -1;
private $currentLine = '';
@ -33,11 +34,13 @@ class Parser
/**
* Constructor.
*
* @param int $offset The offset of YAML document (used for line numbers in error messages)
* @param int $offset The offset of YAML document (used for line numbers in error messages)
* @param int|null $totalNumberOfLines The overall number of lines being parsed
*/
public function __construct($offset = 0)
public function __construct($offset = 0, $totalNumberOfLines = null)
{
$this->offset = $offset;
$this->totalNumberOfLines = $totalNumberOfLines;
}
/**
@ -62,6 +65,10 @@ class Parser
$value = $this->cleanup($value);
$this->lines = explode("\n", $value);
if (null === $this->totalNumberOfLines) {
$this->totalNumberOfLines = count($this->lines);
}
if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('UTF-8');
@ -83,7 +90,7 @@ class Parser
$isRef = $mergeNode = false;
if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) {
if ($context && 'mapping' == $context) {
throw new ParseException('You cannot define a sequence item when in a mapping');
throw new ParseException('You cannot define a sequence item when in a mapping', $this->getRealCurrentLineNb() + 1, $this->currentLine);
}
$context = 'sequence';
@ -95,7 +102,7 @@ class Parser
// array
if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
$c = $this->getRealCurrentLineNb() + 1;
$parser = new self($c);
$parser = new self($c, $this->totalNumberOfLines);
$parser->refs = &$this->refs;
$data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport, $objectForMap);
} else {
@ -104,7 +111,7 @@ class Parser
) {
// this is a compact notation element, add to next block and parse
$c = $this->getRealCurrentLineNb();
$parser = new self($c);
$parser = new self($c, $this->totalNumberOfLines);
$parser->refs = &$this->refs;
$block = $values['value'];
@ -122,7 +129,7 @@ class Parser
}
} elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values) && (false === strpos($values['key'], ' #') || in_array($values['key'][0], array('"', "'")))) {
if ($context && 'sequence' == $context) {
throw new ParseException('You cannot define a mapping item when in a sequence');
throw new ParseException('You cannot define a mapping item when in a sequence', $this->currentLineNb + 1, $this->currentLine);
}
$context = 'mapping';
@ -169,7 +176,7 @@ class Parser
$value = $this->getNextEmbedBlock();
}
$c = $this->getRealCurrentLineNb() + 1;
$parser = new self($c);
$parser = new self($c, $this->totalNumberOfLines);
$parser->refs = &$this->refs;
$parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport, $objectForMap);
@ -220,7 +227,7 @@ class Parser
}
} else {
$c = $this->getRealCurrentLineNb() + 1;
$parser = new self($c);
$parser = new self($c, $this->totalNumberOfLines);
$parser->refs = &$this->refs;
$value = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport, $objectForMap);
// Spec: Keys MUST be unique; first one wins.
@ -243,7 +250,7 @@ class Parser
} else {
// multiple documents are not supported
if ('---' === $this->currentLine) {
throw new ParseException('Multiple documents are not supported.');
throw new ParseException('Multiple documents are not supported.', $this->currentLineNb + 1, $this->currentLine);
}
// 1-liner optionally followed by newline(s)
@ -490,7 +497,7 @@ class Parser
}
if (!array_key_exists($value, $this->refs)) {
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLine);
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine);
}
return $this->refs[$value];
@ -585,6 +592,8 @@ class Parser
if ($notEOF) {
$blockLines[] = '';
$this->moveToPreviousLine();
} elseif (!$notEOF && !$this->isCurrentLineLastLineInDocument()) {
$blockLines[] = '';
}
// folded style
@ -691,6 +700,11 @@ class Parser
return '' !== $ltrimmedLine && $ltrimmedLine[0] === '#';
}
private function isCurrentLineLastLineInDocument()
{
return ($this->offset + $this->currentLineNb) >= ($this->totalNumberOfLines - 1);
}
/**
* Cleanups a YAML string to be parsed.
*
@ -768,7 +782,7 @@ class Parser
*/
private function isStringUnIndentedCollectionItem()
{
return 0 === strpos($this->currentLine, '- ');
return '-' === rtrim($this->currentLine) || 0 === strpos($this->currentLine, '- ');
}
/**

20
vendor/symfony/yaml/README.md поставляемый
Просмотреть файл

@ -1,21 +1,13 @@
Yaml Component
==============
YAML implements most of the YAML 1.2 specification.
```php
use Symfony\Component\Yaml\Yaml;
$array = Yaml::parse(file_get_contents(filename));
print Yaml::dump($array);
```
The Yaml component loads and dumps YAML files.
Resources
---------
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Yaml/
$ composer install
$ phpunit
* [Documentation](https://symfony.com/doc/current/components/yaml/index.html)
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
* [Report issues](https://github.com/symfony/symfony/issues) and
[send Pull Requests](https://github.com/symfony/symfony/pulls)
in the [main Symfony repository](https://github.com/symfony/symfony)

18
vendor/symfony/yaml/Tests/DumperTest.php поставляемый
Просмотреть файл

@ -228,6 +228,24 @@ EOF;
'paragraph-separator' => array("\t\\P", '"\t\\\\P"'),
);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The indentation must be greater than zero
*/
public function testZeroIndentationThrowsException()
{
$this->dumper->setIndentation(0);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The indentation must be greater than zero
*/
public function testNegativeIndentationThrowsException()
{
$this->dumper->setIndentation(-4);
}
}
class A

20
vendor/symfony/yaml/Tests/InlineTest.php поставляемый
Просмотреть файл

@ -220,6 +220,24 @@ class InlineTest extends \PHPUnit_Framework_TestCase
return array(array('|'), array('>'));
}
/**
* @dataProvider getDataForIsHash
*/
public function testIsHash($array, $expected)
{
$this->assertSame($expected, Inline::isHash($array));
}
public function getDataForIsHash()
{
return array(
array(array(), false),
array(array(1, 2, 3), false),
array(array(2 => 1, 1 => 2, 0 => 3), true),
array(array('foo' => 1, 'bar' => 2), true),
);
}
public function getTestsForParse()
{
return array(
@ -426,6 +444,8 @@ class InlineTest extends \PHPUnit_Framework_TestCase
array('[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))),
array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
array('{ foo: { bar: { 1: 2, baz: 3 } } }', array('foo' => array('bar' => array(1 => 2, 'baz' => 3)))),
);
}
}

41
vendor/symfony/yaml/Tests/ParserTest.php поставляемый
Просмотреть файл

@ -596,7 +596,7 @@ EOF;
/**
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
* @expectedExceptionMessage Multiple documents are not supported.
* @expectedExceptionMessageRegExp /^Multiple documents are not supported.+/
*/
public function testMultipleDocumentsNotSupportedException()
{
@ -628,6 +628,34 @@ EOF
);
}
public function testSequenceInMappingStartedBySingleDashLine()
{
$yaml = <<<EOT
a:
-
b:
-
bar: baz
- foo
d: e
EOT;
$expected = array(
'a' => array(
array(
'b' => array(
array(
'bar' => 'baz',
),
),
),
'foo',
),
'd' => 'e',
);
$this->assertSame($expected, $this->parser->parse($yaml));
}
/**
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
*/
@ -889,9 +917,13 @@ EOF;
$deprecations = array();
set_error_handler(function ($type, $msg) use (&$deprecations) {
if (E_USER_DEPRECATED === $type) {
$deprecations[] = $msg;
if (E_USER_DEPRECATED !== $type) {
restore_error_handler();
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
}
$deprecations[] = $msg;
});
$this->parser->parse($yaml);
@ -989,6 +1021,7 @@ EOT
foo
# bar
baz
EOT
,
),
@ -1017,7 +1050,7 @@ EOT;
$expected = array(
'foo' => array(
'bar' => array(
'scalar-block' => 'line1 line2>',
'scalar-block' => "line1 line2>\n",
),
'baz' => array(
'foobar' => null,

18
vendor/symfony/yaml/Tests/YamlTest.php поставляемый
Просмотреть файл

@ -34,4 +34,22 @@ class YamlTest extends \PHPUnit_Framework_TestCase
$parsedByContents = Yaml::parse($contents);
$this->assertEquals($parsedByFilename, $parsedByContents);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The indentation must be greater than zero
*/
public function testZeroIndentationThrowsException()
{
Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, 0);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The indentation must be greater than zero
*/
public function testNegativeIndentationThrowsException()
{
Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, -4);
}
}

4
vendor/symfony/yaml/Yaml.php поставляемый
Просмотреть файл

@ -88,6 +88,10 @@ class Yaml
*/
public static function dump($array, $inline = 2, $indent = 4, $exceptionOnInvalidType = false, $objectSupport = false)
{
if ($indent < 1) {
throw new \InvalidArgumentException('The indentation must be greater than zero.');
}
$yaml = new Dumper();
$yaml->setIndentation($indent);