Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 31ee43a

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: [DependencyInjection] Fixed incorrect report for private services if required service does not exist Remove Xdebug from php-extra runs. Fix checking slack section fields limit
2 parents e97f9e7 + 2b36487 commit 31ee43a

File tree

5 files changed

+104
-3
lines changed

5 files changed

+104
-3
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ before_install:
5858
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
5959
export COMPOSER_UP='composer update --no-progress --ansi'
6060
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n' | sort)
61-
find ~/.phpenv -name xdebug.ini -delete
6261
6362
nanoseconds () {
6463
local cmd="date"
@@ -137,6 +136,7 @@ before_install:
137136
echo extension = memcached.so >> $INI
138137
fi
139138
done
139+
find ~/.phpenv -name xdebug.ini -delete
140140
141141
- |
142142
# Install extra PHP extensions

src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ public function __construct()
7979
new ReplaceAliasByActualDefinitionPass(),
8080
new RemoveAbstractDefinitionsPass(),
8181
new RemoveUnusedDefinitionsPass(),
82+
new AnalyzeServiceReferencesPass(),
83+
new CheckExceptionOnInvalidReferenceBehaviorPass(),
8284
new InlineServiceDefinitionsPass(new AnalyzeServiceReferencesPass()),
8385
new AnalyzeServiceReferencesPass(),
8486
new DefinitionErrorExceptionPass(),
8587
]];
8688

8789
$this->afterRemovingPasses = [[
88-
new CheckExceptionOnInvalidReferenceBehaviorPass(),
8990
new ResolveHotPathPass(),
9091
new ResolveNoPreloadPass(),
9192
new AliasDeprecatedPublicServicesPass(),

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,47 @@ public function testNoClassFromNsSeparatorId()
13371337
$container->compile();
13381338
}
13391339

1340+
public function testGetThrownServiceNotFoundExceptionWithCorrectServiceId()
1341+
{
1342+
$this->expectException(ServiceNotFoundException::class);
1343+
$this->expectExceptionMessage('The service "child_service" has a dependency on a non-existent service "non_existent_service".');
1344+
1345+
$container = new ContainerBuilder();
1346+
$container->register('child_service', \stdClass::class)
1347+
->setPublic(false)
1348+
->addArgument([
1349+
'non_existent' => new Reference('non_existent_service'),
1350+
])
1351+
;
1352+
$container->register('parent_service', \stdClass::class)
1353+
->setPublic(true)
1354+
->addArgument([
1355+
'child_service' => new Reference('child_service'),
1356+
])
1357+
;
1358+
1359+
$container->compile();
1360+
}
1361+
1362+
public function testUnusedServiceRemovedByPassAndServiceNotFoundExceptionWasNotThrown()
1363+
{
1364+
$container = new ContainerBuilder();
1365+
$container->register('service', \stdClass::class)
1366+
->setPublic(false)
1367+
->addArgument([
1368+
'non_existent_service' => new Reference('non_existent_service'),
1369+
])
1370+
;
1371+
1372+
try {
1373+
$container->compile();
1374+
} catch (ServiceNotFoundException $e) {
1375+
$this->fail('Should not be thrown');
1376+
}
1377+
1378+
$this->addToAssertionCount(1);
1379+
}
1380+
13401381
public function testServiceLocator()
13411382
{
13421383
$container = new ContainerBuilder();

src/Symfony/Component/Notifier/Bridge/Slack/Block/SlackSectionBlock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function text(string $text, bool $markdown = true): self
3939
*/
4040
public function field(string $text, bool $markdown = true): self
4141
{
42-
if (10 === \count($this->options['fields'])) {
42+
if (10 === \count($this->options['fields'] ?? [])) {
4343
throw new \LogicException('Maximum number of fields should not exceed 10.');
4444
}
4545

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Bridge\Slack\Tests\Block;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackImageBlockElement;
16+
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackSectionBlock;
17+
18+
final class SlackSectionBlockTest extends TestCase
19+
{
20+
public function testCanBeInstantiated(): void
21+
{
22+
$section = new SlackSectionBlock();
23+
$section->text('section text');
24+
$section->field('section field');
25+
$section->accessory(new SlackImageBlockElement('https://example.com/image.jpg', 'an image'));
26+
27+
$this->assertSame([
28+
'type' => 'section',
29+
'text' => [
30+
'type' => 'mrkdwn',
31+
'text' => 'section text',
32+
],
33+
'fields' => [
34+
[
35+
'type' => 'mrkdwn',
36+
'text' => 'section field',
37+
],
38+
],
39+
'accessory' => [
40+
'type' => 'image',
41+
'image_url' => 'https://example.com/image.jpg',
42+
'alt_text' => 'an image',
43+
],
44+
], $section->toArray());
45+
}
46+
47+
public function testThrowsWhenFieldsLimitReached(): void
48+
{
49+
$section = new SlackSectionBlock();
50+
for ($i = 0; $i < 10; ++$i) {
51+
$section->field($i);
52+
}
53+
54+
$this->expectException(\LogicException::class);
55+
$this->expectExceptionMessage('Maximum number of fields should not exceed 10.');
56+
57+
$section->field('fail');
58+
}
59+
}

0 commit comments

Comments
 (0)