This repository has been archived by the owner on Jul 22, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 21
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 #54 from stphnpt/0.x
Check for a valid object in `BlockAdmin::toString`
- Loading branch information
Showing
5 changed files
with
106 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\DashboardBundle\Tests\Admin; | ||
|
||
use Sonata\AdminBundle\Admin\Admin; | ||
use Sonata\DashboardBundle\Admin\BlockAdmin; | ||
use Sonata\DashboardBundle\Tests\Fixtures\Entity\FooGetName; | ||
use Sonata\DashboardBundle\Tests\Fixtures\Entity\FooGetNameNull; | ||
use Sonata\DashboardBundle\Tests\Fixtures\Entity\FooNoGetName; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* BlockAdminTest. | ||
* | ||
* @author Stéphane Paté <[email protected]> | ||
*/ | ||
final class BlockAdminTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testToString() | ||
{ | ||
$admin = new BlockAdmin( | ||
'sonata.dashboard.admin.block', | ||
'DashboardBundle\Entity\BaseBlock', | ||
'SonataDashboardBundle:BlockAdmin' | ||
); | ||
|
||
$s = new FooGetName(); | ||
$this->assertSame('GetName', $admin->toString($s)); | ||
|
||
$s = new FooGetNameNull(); | ||
$this->assertSame('GetNameNull', $admin->toString($s)); | ||
|
||
$s = new FooNoGetName(); | ||
$this->assertSame('NoGetName', $admin->toString($s)); | ||
} | ||
|
||
public function testGetPersistentParameters() | ||
{ | ||
$admin = new BlockAdmin( | ||
'sonata.dashboard.admin.block', | ||
'DashboardBundle\Entity\BaseBlock', | ||
'SonataDashboardBundle:BlockAdmin' | ||
); | ||
|
||
$request = new Request(); | ||
$admin->setRequest($request); | ||
|
||
$this->assertArrayHasKey('type', $admin->getPersistentParameters()); | ||
} | ||
} |
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,11 @@ | ||
<?php | ||
|
||
namespace Sonata\DashboardBundle\Tests\Fixtures\Entity; | ||
|
||
final class FooGetName | ||
{ | ||
public function getName() | ||
{ | ||
return 'GetName'; | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace Sonata\DashboardBundle\Tests\Fixtures\Entity; | ||
|
||
final class FooGetNameNull | ||
{ | ||
public function getName() | ||
{ | ||
return; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return 'GetNameNull'; | ||
} | ||
} |
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,11 @@ | ||
<?php | ||
|
||
namespace Sonata\DashboardBundle\Tests\Fixtures\Entity; | ||
|
||
final class FooNoGetName | ||
{ | ||
public function __toString() | ||
{ | ||
return 'NoGetName'; | ||
} | ||
} |