Skip to content

Commit e768f37

Browse files
committed
Merge branch '2.3' into 2.4
* 2.3: Make Doctrine's dependency injection test less fragile. [Finder] [Iterator] Make the tests less fragile [Form][DateTime] Propagate invalid_message & invalid_message parameters to date & time sub widgets
2 parents da4e85e + 2ecbf87 commit e768f37

File tree

5 files changed

+87
-36
lines changed

5 files changed

+87
-36
lines changed

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ public function testProcessEventSubscribersWithPriorities()
132132
;
133133

134134
$this->process($container);
135-
$this->assertEquals(array('c', 'd', 'e', 'b', 'a'), $this->getServiceOrder($container, 'addEventSubscriber'));
135+
$serviceOrder = $this->getServiceOrder($container, 'addEventSubscriber');
136+
$unordered = array_splice($serviceOrder, 0, 3);
137+
sort($unordered);
138+
$this->assertEquals(array('c', 'd', 'e'), $unordered);
139+
$this->assertEquals(array('b', 'a'), $serviceOrder);
136140
}
137141

138142
public function testProcessNoTaggedServices()

src/Symfony/Component/Finder/Tests/Iterator/IteratorTestCase.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,31 @@ protected function assertOrderedIterator($expected, \Traversable $iterator)
3434
$this->assertEquals($expected, array_values($values));
3535
}
3636

37+
/**
38+
* Same as assertOrderedIterator, but checks the order of groups of
39+
* array elements.
40+
*
41+
* @param array $expected - an array of arrays. For any two subarrays
42+
* $a and $b such that $a goes before $b in $expected, the method
43+
* asserts that any element of $a goes before any element of $b
44+
* in the sequence generated by $iterator
45+
* @param \Traversable $iterator
46+
*/
47+
protected function assertOrderedIteratorForGroups($expected, \Traversable $iterator)
48+
{
49+
$values = array_values(array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator)));
50+
51+
foreach ($expected as $subarray) {
52+
$temp = array();
53+
while (count($values) && count($temp) < count($subarray)) {
54+
array_push($temp, array_shift($values));
55+
}
56+
sort($temp);
57+
sort($subarray);
58+
$this->assertEquals($subarray, $temp);
59+
}
60+
}
61+
3762
/**
3863
* Same as IteratorTestCase::assertIterator with foreach usage
3964
*

src/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ protected static function toAbsolute($files = null)
8080
if (is_array($files)) {
8181
$f = array();
8282
foreach ($files as $file) {
83-
$f[] = self::$tmpDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $file);
83+
if (is_array($file)) {
84+
$f[] = self::toAbsolute($file);
85+
} else {
86+
$f[] = self::$tmpDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $file);
87+
}
8488
}
8589

8690
return $f;

src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ public function testAccept($mode, $expected)
5454

5555
$iterator = new SortableIterator($inner, $mode);
5656

57-
$this->assertOrderedIterator($expected, $iterator);
57+
if ($mode === SortableIterator::SORT_BY_ACCESSED_TIME
58+
|| $mode === SortableIterator::SORT_BY_CHANGED_TIME
59+
|| $mode === SortableIterator::SORT_BY_MODIFIED_TIME) {
60+
$this->assertOrderedIteratorForGroups($expected, $iterator);
61+
} else {
62+
$this->assertOrderedIterator($expected, $iterator);
63+
}
5864
}
5965

6066
public function getAcceptData()
@@ -102,45 +108,53 @@ public function getAcceptData()
102108
);
103109

104110
$sortByAccessedTime = array(
105-
'foo/bar.tmp',
106-
'test.php',
107-
'toto',
108-
'foo bar',
109-
'foo',
110-
'test.py',
111-
'.foo',
112-
'.foo/.bar',
113-
'.foo/bar',
114-
'.git',
115-
'.bar',
111+
// For these two files the access time was set to 2005-10-15
112+
array('foo/bar.tmp', 'test.php'),
113+
// These files were created more or less at the same time
114+
array(
115+
'.git',
116+
'.foo',
117+
'.foo/.bar',
118+
'.foo/bar',
119+
'test.py',
120+
'foo',
121+
'toto',
122+
'foo bar',
123+
),
124+
// This file was accessed after sleeping for 1 sec
125+
array('.bar'),
116126
);
117127

118128
$sortByChangedTime = array(
119-
'foo',
120-
'foo/bar.tmp',
121-
'toto',
122-
'.git',
123-
'.bar',
124-
'.foo',
125-
'foo bar',
126-
'.foo/.bar',
127-
'.foo/bar',
128-
'test.php',
129-
'test.py',
129+
array(
130+
'.git',
131+
'.foo',
132+
'.foo/.bar',
133+
'.foo/bar',
134+
'.bar',
135+
'foo',
136+
'foo/bar.tmp',
137+
'toto',
138+
'foo bar',
139+
),
140+
array('test.php'),
141+
array('test.py'),
130142
);
131143

132144
$sortByModifiedTime = array(
133-
'foo/bar.tmp',
134-
'foo',
135-
'toto',
136-
'.git',
137-
'.bar',
138-
'.foo',
139-
'foo bar',
140-
'.foo/.bar',
141-
'.foo/bar',
142-
'test.php',
143-
'test.py',
145+
array(
146+
'.git',
147+
'.foo',
148+
'.foo/.bar',
149+
'.foo/bar',
150+
'.bar',
151+
'foo',
152+
'foo/bar.tmp',
153+
'toto',
154+
'foo bar',
155+
),
156+
array('test.php'),
157+
array('test.py'),
144158
);
145159

146160
return array(

src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
117117
'empty_value',
118118
'required',
119119
'translation_domain',
120+
'invalid_message',
121+
'invalid_message_parameters',
120122
)));
121123

122124
$timeOptions = array_intersect_key($options, array_flip(array(
@@ -128,6 +130,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
128130
'empty_value',
129131
'required',
130132
'translation_domain',
133+
'invalid_message',
134+
'invalid_message_parameters',
131135
)));
132136

133137
if (null !== $options['date_widget']) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy