-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af7a90a
commit 81b5038
Showing
5 changed files
with
184 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* 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\DoctrineORMAdminBundle\Tests\App\Admin; | ||
|
||
use Sonata\AdminBundle\Admin\AbstractAdmin; | ||
use Sonata\AdminBundle\Datagrid\DatagridMapper; | ||
use Sonata\AdminBundle\Datagrid\ListMapper; | ||
use Sonata\AdminBundle\Form\FormMapper; | ||
use Symfony\Component\Form\Extension\Core\Type\IntegerType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
|
||
final class CarAdmin extends AbstractAdmin | ||
{ | ||
protected function configureListFields(ListMapper $list): void | ||
{ | ||
$list | ||
->add('name') | ||
->add('year'); | ||
} | ||
|
||
protected function configureDatagridFilters(DatagridMapper $filter): void | ||
{ | ||
$filter | ||
->add('name') | ||
->add('year'); | ||
} | ||
|
||
protected function configureFormFields(FormMapper $form): void | ||
{ | ||
$form | ||
->add('name', TextType::class) | ||
->add('year', IntegerType::class); | ||
} | ||
} |
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 | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* 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\DoctrineORMAdminBundle\Tests\App\DataFixtures; | ||
|
||
use Doctrine\Bundle\FixturesBundle\Fixture; | ||
use Doctrine\Persistence\ObjectManager; | ||
use Sonata\DoctrineORMAdminBundle\Tests\App\Entity\Car; | ||
|
||
final class CarFixtures extends Fixture | ||
{ | ||
public function load(ObjectManager $manager): void | ||
{ | ||
$peugeot2000 = new Car('Peugeot', 2000); | ||
$peugeot2010 = new Car('Peugeot', 2010); | ||
$ferrari2000 = new Car('Ferrari', 2000); | ||
|
||
$manager->persist($peugeot2000); | ||
$manager->persist($peugeot2010); | ||
$manager->persist($ferrari2000); | ||
$manager->flush(); | ||
} | ||
} |
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,67 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* 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\DoctrineORMAdminBundle\Tests\App\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** @ORM\Entity */ | ||
class Car | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\Column(type="string") | ||
* | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @ORM\Id | ||
* @ORM\Column(type="integer") | ||
* | ||
* @var int | ||
*/ | ||
private $year; | ||
|
||
public function __construct(string $name = '', int $year = 0) | ||
{ | ||
$this->name = $name; | ||
$this->year = $year; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return $this->name.' - '.$this->year; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName(string $name): void | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public function getYear(): int | ||
{ | ||
return $this->year; | ||
} | ||
|
||
public function setYear(int $year): void | ||
{ | ||
$this->year = $year; | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* 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\DoctrineORMAdminBundle\Tests\Functional; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
final class CompositePrimaryKeysTest extends BasePantherTestCase | ||
{ | ||
public function testListCompositePrimaryKeys(): void | ||
{ | ||
$this->client->request(Request::METHOD_GET, '/admin/tests/app/car/list'); | ||
|
||
self::assertSelectorTextContains('.box-footer', '1 / 1 - 3 results'); | ||
} | ||
} |