Skip to content

Commit

Permalink
Fix trigger_error messages (#6660)
Browse files Browse the repository at this point in the history
The parameters passed to sprintf were in the wrong order.
  • Loading branch information
franmomu authored Dec 7, 2020
1 parent ff709e6 commit 78b44ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Admin/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,10 @@ public function getTemplate($name)
public function getTitleLogo()
{
@trigger_error(sprintf(
'The "%s" method is deprecated since version 3.x and will be removed in 4.0.'
.' Use "%s::getTitle()" instead.',
SonataConfiguration::class,
__METHOD__
'The "%s()" method is deprecated since version 3.x and will be removed in 4.0.'
.' Use "%s::getLogo()" instead.',
__METHOD__,
SonataConfiguration::class
), E_USER_DEPRECATED);

return $this->titleLogo;
Expand All @@ -574,10 +574,10 @@ public function getTitleLogo()
public function getTitle()
{
@trigger_error(sprintf(
'The "%s" method is deprecated since version 3.x and will be removed in 4.0.'
.' Use "%s::getLogo()" instead.',
SonataConfiguration::class,
__METHOD__
'The "%s()" method is deprecated since version 3.x and will be removed in 4.0.'
.' Use "%s::getTitle()" instead.',
__METHOD__,
SonataConfiguration::class
), E_USER_DEPRECATED);

return $this->title;
Expand All @@ -596,10 +596,10 @@ public function getTitle()
public function getOption($name, $default = null)
{
@trigger_error(sprintf(
'The "%s" method is deprecated since version 3.x and will be removed in 4.0.'
'The "%s()" method is deprecated since version 3.x and will be removed in 4.0.'
.' Use "%s::getOption()" instead.',
SonataConfiguration::class,
__METHOD__
__METHOD__,
SonataConfiguration::class
), E_USER_DEPRECATED);

if (isset($this->options[$name])) {
Expand Down
11 changes: 11 additions & 0 deletions tests/Admin/PoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
use Sonata\AdminBundle\Admin\AdminInterface;
use Sonata\AdminBundle\Admin\Pool;
use Sonata\AdminBundle\Templating\MutableTemplateRegistryInterface;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;

class PoolTest extends TestCase
{
use ExpectDeprecationTrait;

/**
* @var Container
*/
Expand Down Expand Up @@ -543,6 +546,8 @@ public function testSetGetTemplates(): void
*/
public function testGetTitleLogo(): void
{
$this->expectDeprecation('The "Sonata\AdminBundle\Admin\Pool::getTitleLogo()" method is deprecated since version 3.x and will be removed in 4.0. Use "Sonata\AdminBundle\SonataConfiguration::getLogo()" instead.');

$this->assertSame('/path/to/pic.png', $this->pool->getTitleLogo());
}

Expand All @@ -553,6 +558,8 @@ public function testGetTitleLogo(): void
*/
public function testGetTitle(): void
{
$this->expectDeprecation('The "Sonata\AdminBundle\Admin\Pool::getTitle()" method is deprecated since version 3.x and will be removed in 4.0. Use "Sonata\AdminBundle\SonataConfiguration::getTitle()" instead.');

$this->assertSame('Sonata Admin', $this->pool->getTitle());
}

Expand All @@ -565,6 +572,8 @@ public function testGetOption(): void
{
$this->assertSame('bar', $this->pool->getOption('foo'));

$this->expectDeprecation('The "Sonata\AdminBundle\Admin\Pool::getOption()" method is deprecated since version 3.x and will be removed in 4.0. Use "Sonata\AdminBundle\SonataConfiguration::getOption()" instead.');

$this->assertNull($this->pool->getOption('non_existent_option'));
}

Expand All @@ -575,6 +584,8 @@ public function testGetOption(): void
*/
public function testOptionDefault(): void
{
$this->expectDeprecation('The "Sonata\AdminBundle\Admin\Pool::getOption()" method is deprecated since version 3.x and will be removed in 4.0. Use "Sonata\AdminBundle\SonataConfiguration::getOption()" instead.');

$this->assertSame([], $this->pool->getOption('nonexistantarray', []));
}

Expand Down

0 comments on commit 78b44ac

Please sign in to comment.