-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3212 from Soullivaneuh/block-settings
Fix deprecated BlockService::setDefaultSettings usage
- Loading branch information
Showing
8 changed files
with
203 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\AdminBundle\Tests\Block; | ||
|
||
use Sonata\AdminBundle\Admin\Pool; | ||
use Sonata\AdminBundle\Block\AdminListBlockService; | ||
use Sonata\BlockBundle\Tests\Block\AbstractBlockServiceTest; | ||
|
||
/** | ||
* @author Sullivan Senechal <soullivaneuh@gmail.com> | ||
*/ | ||
class AdminListBlockServiceTest extends AbstractBlockServiceTest | ||
{ | ||
/** | ||
* @var Pool | ||
*/ | ||
private $pool; | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->pool = $this->getMockBuilder('Sonata\AdminBundle\Admin\Pool')->disableOriginalConstructor()->getMock(); | ||
} | ||
|
||
public function testDefaultSettings() | ||
{ | ||
$blockService = new AdminListBlockService('foo', $this->templating, $this->pool); | ||
$blockContext = $this->getBlockContext($blockService); | ||
|
||
$this->assertSettings(array( | ||
'groups' => false, | ||
), $blockContext); | ||
} | ||
|
||
public function testOverriddenDefaultSettings() | ||
{ | ||
$blockService = new FakeBlockService('foo', $this->templating, $this->pool); | ||
$blockContext = $this->getBlockContext($blockService); | ||
|
||
$this->assertSettings(array( | ||
'foo' => 'bar', | ||
'groups' => true, | ||
), $blockContext); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\AdminBundle\Tests\Block; | ||
|
||
use Sonata\AdminBundle\Admin\Pool; | ||
use Sonata\AdminBundle\Block\AdminSearchBlockService; | ||
use Sonata\AdminBundle\Search\SearchHandler; | ||
use Sonata\BlockBundle\Tests\Block\AbstractBlockServiceTest; | ||
|
||
/** | ||
* @author Sullivan Senechal <soullivaneuh@gmail.com> | ||
*/ | ||
class AdminSearchBlockServiceTest extends AbstractBlockServiceTest | ||
{ | ||
/** | ||
* @var Pool | ||
*/ | ||
private $pool; | ||
|
||
/** | ||
* @var SearchHandler | ||
*/ | ||
private $searchHandler; | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->pool = $this->getMockBuilder('Sonata\AdminBundle\Admin\Pool')->disableOriginalConstructor()->getMock(); | ||
$this->searchHandler = $this->getMockBuilder('Sonata\AdminBundle\Search\SearchHandler')->disableOriginalConstructor()->getMock(); | ||
} | ||
|
||
public function testDefaultSettings() | ||
{ | ||
$blockService = new AdminSearchBlockService('foo', $this->templating, $this->pool, $this->searchHandler); | ||
$blockContext = $this->getBlockContext($blockService); | ||
|
||
$this->assertSettings(array( | ||
'admin_code' => false, | ||
'query' => '', | ||
'page' => 0, | ||
'per_page' => 10, | ||
), $blockContext); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\AdminBundle\Tests\Block; | ||
|
||
use Sonata\AdminBundle\Admin\Pool; | ||
use Sonata\AdminBundle\Block\AdminStatsBlockService; | ||
use Sonata\BlockBundle\Tests\Block\AbstractBlockServiceTest; | ||
|
||
/** | ||
* @author Sullivan Senechal <soullivaneuh@gmail.com> | ||
*/ | ||
class AdminStatsBlockServiceTest extends AbstractBlockServiceTest | ||
{ | ||
/** | ||
* @var Pool | ||
*/ | ||
private $pool; | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->pool = $this->getMockBuilder('Sonata\AdminBundle\Admin\Pool')->disableOriginalConstructor()->getMock(); | ||
} | ||
|
||
public function testDefaultSettings() | ||
{ | ||
$blockService = new AdminStatsBlockService('foo', $this->templating, $this->pool); | ||
$blockContext = $this->getBlockContext($blockService); | ||
|
||
$this->assertSettings(array( | ||
'icon' => 'fa-line-chart', | ||
'text' => 'Statistics', | ||
'color' => 'bg-aqua', | ||
'code' => false, | ||
'filters' => array(), | ||
'limit' => 1000, | ||
'template' => 'SonataAdminBundle:Block:block_stats.html.twig', | ||
), $blockContext); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\AdminBundle\Tests\Block; | ||
|
||
use Sonata\AdminBundle\Block\AdminListBlockService; | ||
use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
|
||
/** | ||
* @author Sullivan Senechal <soullivaneuh@gmail.com> | ||
*/ | ||
class FakeBlockService extends AdminListBlockService | ||
{ | ||
public function setDefaultSettings(OptionsResolverInterface $resolver) | ||
{ | ||
parent::setDefaultSettings($resolver); | ||
|
||
$resolver | ||
->setDefaults(array( | ||
'foo' => 'bar', | ||
'groups' => true, | ||
)) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters