Merge branch '2.3' into 2.7
This commit is contained in:
commit
fff265d451
@ -29,6 +29,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'date_widget' => 'choice',
|
'date_widget' => 'choice',
|
||||||
|
'years' => array(2010),
|
||||||
'time_widget' => 'choice',
|
'time_widget' => 'choice',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
));
|
));
|
||||||
@ -57,6 +58,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'date_widget' => 'choice',
|
'date_widget' => 'choice',
|
||||||
|
'years' => array(2010),
|
||||||
'time_widget' => 'choice',
|
'time_widget' => 'choice',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -82,6 +84,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'timestamp',
|
'input' => 'timestamp',
|
||||||
'date_widget' => 'choice',
|
'date_widget' => 'choice',
|
||||||
|
'years' => array(2010),
|
||||||
'time_widget' => 'choice',
|
'time_widget' => 'choice',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -108,12 +111,13 @@ class DateTimeTypeTest extends TestCase
|
|||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'date_widget' => 'choice',
|
'date_widget' => 'choice',
|
||||||
|
'years' => array(2010),
|
||||||
'time_widget' => 'choice',
|
'time_widget' => 'choice',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'with_minutes' => false,
|
'with_minutes' => false,
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->setData(new \DateTime('2010-06-02 03:04:05 UTC'));
|
$form->setData(new \DateTime());
|
||||||
|
|
||||||
$input = array(
|
$input = array(
|
||||||
'date' => array(
|
'date' => array(
|
||||||
@ -137,12 +141,13 @@ class DateTimeTypeTest extends TestCase
|
|||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'date_widget' => 'choice',
|
'date_widget' => 'choice',
|
||||||
|
'years' => array(2010),
|
||||||
'time_widget' => 'choice',
|
'time_widget' => 'choice',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
$form->setData(new \DateTime('2010-06-02 03:04:05 UTC'));
|
$form->setData(new \DateTime());
|
||||||
|
|
||||||
$input = array(
|
$input = array(
|
||||||
'date' => array(
|
'date' => array(
|
||||||
@ -168,6 +173,7 @@ class DateTimeTypeTest extends TestCase
|
|||||||
'model_timezone' => 'America/New_York',
|
'model_timezone' => 'America/New_York',
|
||||||
'view_timezone' => 'Pacific/Tahiti',
|
'view_timezone' => 'Pacific/Tahiti',
|
||||||
'date_widget' => 'choice',
|
'date_widget' => 'choice',
|
||||||
|
'years' => array(2010),
|
||||||
'time_widget' => 'choice',
|
'time_widget' => 'choice',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
|
@ -187,6 +187,7 @@ class DateTypeTest extends TestCase
|
|||||||
'model_timezone' => 'UTC',
|
'model_timezone' => 'UTC',
|
||||||
'view_timezone' => 'UTC',
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
|
'years' => array(2010),
|
||||||
));
|
));
|
||||||
|
|
||||||
$text = array(
|
$text = array(
|
||||||
|
@ -343,7 +343,11 @@ class Parser
|
|||||||
private function getNextEmbedBlock($indentation = null, $inSequence = false)
|
private function getNextEmbedBlock($indentation = null, $inSequence = false)
|
||||||
{
|
{
|
||||||
$oldLineIndentation = $this->getCurrentLineIndentation();
|
$oldLineIndentation = $this->getCurrentLineIndentation();
|
||||||
$insideBlockScalar = $this->isBlockScalarHeader();
|
$blockScalarIndentations = array();
|
||||||
|
|
||||||
|
if ($this->isBlockScalarHeader()) {
|
||||||
|
$blockScalarIndentations[] = $this->getCurrentLineIndentation();
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->moveToNextLine()) {
|
if (!$this->moveToNextLine()) {
|
||||||
return;
|
return;
|
||||||
@ -380,8 +384,8 @@ class Parser
|
|||||||
|
|
||||||
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem();
|
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem();
|
||||||
|
|
||||||
if (!$insideBlockScalar) {
|
if (empty($blockScalarIndentations) && $this->isBlockScalarHeader()) {
|
||||||
$insideBlockScalar = $this->isBlockScalarHeader();
|
$blockScalarIndentations[] = $this->getCurrentLineIndentation();
|
||||||
}
|
}
|
||||||
|
|
||||||
$previousLineIndentation = $this->getCurrentLineIndentation();
|
$previousLineIndentation = $this->getCurrentLineIndentation();
|
||||||
@ -389,8 +393,17 @@ class Parser
|
|||||||
while ($this->moveToNextLine()) {
|
while ($this->moveToNextLine()) {
|
||||||
$indent = $this->getCurrentLineIndentation();
|
$indent = $this->getCurrentLineIndentation();
|
||||||
|
|
||||||
if (!$insideBlockScalar && $indent === $previousLineIndentation) {
|
// terminate all block scalars that are more indented than the current line
|
||||||
$insideBlockScalar = $this->isBlockScalarHeader();
|
if (!empty($blockScalarIndentations) && $indent < $previousLineIndentation && trim($this->currentLine) !== '') {
|
||||||
|
foreach ($blockScalarIndentations as $key => $blockScalarIndentation) {
|
||||||
|
if ($blockScalarIndentation >= $this->getCurrentLineIndentation()) {
|
||||||
|
unset($blockScalarIndentations[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($blockScalarIndentations) && !$this->isCurrentLineComment() && $this->isBlockScalarHeader()) {
|
||||||
|
$blockScalarIndentations[] = $this->getCurrentLineIndentation();
|
||||||
}
|
}
|
||||||
|
|
||||||
$previousLineIndentation = $indent;
|
$previousLineIndentation = $indent;
|
||||||
@ -406,7 +419,7 @@ class Parser
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we ignore "comment" lines only when we are not inside a scalar block
|
// we ignore "comment" lines only when we are not inside a scalar block
|
||||||
if (!$insideBlockScalar && $this->isCurrentLineComment()) {
|
if (empty($blockScalarIndentations) && $this->isCurrentLineComment()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,7 +577,7 @@ class Parser
|
|||||||
$previousLineIndented = false;
|
$previousLineIndented = false;
|
||||||
$previousLineBlank = false;
|
$previousLineBlank = false;
|
||||||
|
|
||||||
for ($i = 0; $i < count($blockLines); $i++) {
|
for ($i = 0; $i < count($blockLines); ++$i) {
|
||||||
if ('' === $blockLines[$i]) {
|
if ('' === $blockLines[$i]) {
|
||||||
$text .= "\n";
|
$text .= "\n";
|
||||||
$previousLineIndented = false;
|
$previousLineIndented = false;
|
||||||
@ -659,7 +672,7 @@ class Parser
|
|||||||
//checking explicitly the first char of the trim is faster than loops or strpos
|
//checking explicitly the first char of the trim is faster than loops or strpos
|
||||||
$ltrimmedLine = ltrim($this->currentLine, ' ');
|
$ltrimmedLine = ltrim($this->currentLine, ' ');
|
||||||
|
|
||||||
return $ltrimmedLine[0] === '#';
|
return '' !== $ltrimmedLine && $ltrimmedLine[0] === '#';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -816,7 +816,9 @@ EOF;
|
|||||||
|
|
||||||
public function getCommentLikeStringInScalarBlockData()
|
public function getCommentLikeStringInScalarBlockData()
|
||||||
{
|
{
|
||||||
$yaml1 = <<<'EOT'
|
$tests = array();
|
||||||
|
|
||||||
|
$yaml = <<<'EOT'
|
||||||
pages:
|
pages:
|
||||||
-
|
-
|
||||||
title: some title
|
title: some title
|
||||||
@ -831,7 +833,7 @@ pages:
|
|||||||
|
|
||||||
footer # comment3
|
footer # comment3
|
||||||
EOT;
|
EOT;
|
||||||
$expected1 = array(
|
$expected = array(
|
||||||
'pages' => array(
|
'pages' => array(
|
||||||
array(
|
array(
|
||||||
'title' => 'some title',
|
'title' => 'some title',
|
||||||
@ -850,8 +852,9 @@ EOT
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
$tests[] = array($yaml, $expected);
|
||||||
|
|
||||||
$yaml2 = <<<'EOT'
|
$yaml = <<<'EOT'
|
||||||
test: |
|
test: |
|
||||||
foo
|
foo
|
||||||
# bar
|
# bar
|
||||||
@ -866,7 +869,7 @@ collection:
|
|||||||
# bar
|
# bar
|
||||||
baz
|
baz
|
||||||
EOT;
|
EOT;
|
||||||
$expected2 = array(
|
$expected = array(
|
||||||
'test' => <<<'EOT'
|
'test' => <<<'EOT'
|
||||||
foo
|
foo
|
||||||
# bar
|
# bar
|
||||||
@ -893,11 +896,47 @@ EOT
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
$tests[] = array($yaml, $expected);
|
||||||
|
|
||||||
return array(
|
$yaml = <<<EOT
|
||||||
array($yaml1, $expected1),
|
foo:
|
||||||
array($yaml2, $expected2),
|
bar:
|
||||||
|
scalar-block: >
|
||||||
|
line1
|
||||||
|
line2>
|
||||||
|
baz:
|
||||||
|
# comment
|
||||||
|
foobar: ~
|
||||||
|
EOT;
|
||||||
|
$expected = array(
|
||||||
|
'foo' => array(
|
||||||
|
'bar' => array(
|
||||||
|
'scalar-block' => 'line1 line2>',
|
||||||
|
),
|
||||||
|
'baz' => array(
|
||||||
|
'foobar' => null,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
$tests[] = array($yaml, $expected);
|
||||||
|
|
||||||
|
$yaml = <<<'EOT'
|
||||||
|
a:
|
||||||
|
b: hello
|
||||||
|
# c: |
|
||||||
|
# first row
|
||||||
|
# second row
|
||||||
|
d: hello
|
||||||
|
EOT;
|
||||||
|
$expected = array(
|
||||||
|
'a' => array(
|
||||||
|
'b' => 'hello',
|
||||||
|
'd' => 'hello',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$tests[] = array($yaml, $expected);
|
||||||
|
|
||||||
|
return $tests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBlankLinesAreParsedAsNewLinesInFoldedBlocks()
|
public function testBlankLinesAreParsedAsNewLinesInFoldedBlocks()
|
||||||
|
Reference in New Issue
Block a user