Skip to content

Commit

Permalink
Improve tests fixtures (#6192)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored Jul 12, 2020
1 parent fafa708 commit 5d69f28
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 42 deletions.
5 changes: 3 additions & 2 deletions tests/App/Admin/FooAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\AdminBundle\Templating\TemplateRegistry;
use Symfony\Component\Form\Extension\Core\Type\TextType;

final class FooAdmin extends AbstractAdmin
{
protected function configureListFields(ListMapper $list)
{
$list->add('name', 'string');
$list->add('name', TemplateRegistry::TYPE_STRING);
}

protected function configureFormFields(FormMapper $form)
Expand All @@ -33,6 +34,6 @@ protected function configureFormFields(FormMapper $form)

protected function configureShowFields(ShowMapper $show)
{
$show->add('name', 'string');
$show->add('name', TemplateRegistry::TYPE_STRING);
}
}
7 changes: 7 additions & 0 deletions tests/App/Builder/DatagridBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@

final class DatagridBuilder implements DatagridBuilderInterface
{
/**
* @var FormFactoryInterface
*/
private $formFactory;

/**
* @var PagerInterface
*/
private $pager;

public function __construct(FormFactoryInterface $formFactory, PagerInterface $pager)
Expand Down
3 changes: 3 additions & 0 deletions tests/App/Builder/FormContractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

final class FormContractor implements FormContractorInterface
{
/**
* @var FormFactoryInterface
*/
private $formFactory;

public function __construct(FormFactoryInterface $formFactory)
Expand Down
18 changes: 18 additions & 0 deletions tests/App/Datagrid/Datagrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Sonata\AdminBundle\Tests\App\Datagrid;

use Sonata\AdminBundle\Admin\FieldDescriptionInterface;
use Sonata\AdminBundle\Datagrid\DatagridInterface;
use Sonata\AdminBundle\Datagrid\PagerInterface;
use Sonata\AdminBundle\Filter\FilterInterface;
Expand All @@ -21,7 +22,14 @@

final class Datagrid implements DatagridInterface
{
/**
* @var FormFactoryInterface
*/
private $formFactory;

/**
* @var PagerInterface
*/
private $pager;

public function __construct(FormFactoryInterface $formFactory, PagerInterface $pager)
Expand Down Expand Up @@ -104,4 +112,14 @@ public function hasDisplayableFilters()
{
return false;
}

public function getSortParameters(FieldDescriptionInterface $fieldDescription): array
{
return [];
}

public function getPaginationParameters(int $page): array
{
return [];
}
}
3 changes: 3 additions & 0 deletions tests/App/Datagrid/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

final class Pager implements PagerInterface
{
/**
* @var FooRepository
*/
private $repository;

public function __construct(FooRepository $repository)
Expand Down
6 changes: 6 additions & 0 deletions tests/App/Model/Foo.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@

final class Foo
{
/**
* @var string
*/
private $id;

/**
* @var string
*/
private $name;

public function __construct(string $id, string $name)
Expand Down
3 changes: 3 additions & 0 deletions tests/App/Model/FooRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

final class FooRepository
{
/**
* @var Foo[]
*/
private $elements;

public function __construct()
Expand Down
8 changes: 8 additions & 0 deletions tests/App/Model/ModelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

final class ModelManager implements ModelManagerInterface
{
/**
* @var FooRepository
*/
private $repository;

public function __construct(FooRepository $repository)
Expand Down Expand Up @@ -146,6 +149,11 @@ public function getDefaultSortValues($class)
return [];
}

public function getDefaultPerPageOptions(string $class): array
{
return [];
}

public function modelReverseTransform($class, array $array = [])
{
throw new \BadMethodCallException('Not implemented.');
Expand Down
12 changes: 6 additions & 6 deletions tests/Fixtures/Admin/FieldDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class FieldDescription extends BaseFieldDescription
{
public function setAssociationMapping($associationMapping): void
{
// TODO: Implement setAssociationMapping() method.
throw new \BadMethodCallException(sprintf('Implement %s() method.', __METHOD__));
}

public function getTargetEntity(): void
{
// TODO: Implement getTargetEntity() method.
throw new \BadMethodCallException(sprintf('Implement %s() method.', __METHOD__));
}

public function getTargetModel(): ?string
Expand All @@ -34,12 +34,12 @@ public function getTargetModel(): ?string

public function setFieldMapping($fieldMapping): void
{
// TODO: Implement setFieldMapping() method.
throw new \BadMethodCallException(sprintf('Implement %s() method.', __METHOD__));
}

public function isIdentifier(): void
{
// TODO: Implement isIdentifier() method.
throw new \BadMethodCallException(sprintf('Implement %s() method.', __METHOD__));
}

/**
Expand All @@ -49,7 +49,7 @@ public function isIdentifier(): void
*/
public function setParentAssociationMappings(array $parentAssociationMappings): void
{
// TODO: Implement setParentAssociationMappings() method.
throw new \BadMethodCallException(sprintf('Implement %s() method.', __METHOD__));
}

/**
Expand All @@ -61,6 +61,6 @@ public function setParentAssociationMappings(array $parentAssociationMappings):
*/
public function getValue($object)
{
// TODO: Implement getValue() method.
throw new \BadMethodCallException(sprintf('Implement %s() method.', __METHOD__));
}
}
16 changes: 0 additions & 16 deletions tests/Fixtures/Admin/PostAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,11 @@

class PostAdmin extends AbstractAdmin
{
protected $metadataClass;

public function setParentAssociationMapping($associationMapping): void
{
$this->parentAssociationMapping = $associationMapping;
}

public function setClassMetaData($classMetaData): void
{
$this->classMetaData = $classMetaData;
}

public function getClassMetaData()
{
if ($this->classMetaData) {
return $this->classMetaData;
}

return parent::getClassMetaData();
}

/**
* @param array $actions
*
Expand Down
3 changes: 3 additions & 0 deletions tests/Fixtures/Bundle/DemoAdminBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

class DemoAdminBundle extends Bundle
{
/**
* @var string
*/
protected $path;

public function setPath($path): void
Expand Down
6 changes: 0 additions & 6 deletions tests/Fixtures/Controller/AbstractFooAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@

namespace Sonata\AdminBundle\Tests\Fixtures\Controller;

/**
* Some documentation about abstract controller.
*/
abstract class AbstractFooAdminController
{
/**
* Bar action.
*/
public function bazAction(): void
{
}
Expand Down
6 changes: 0 additions & 6 deletions tests/Fixtures/Controller/BarAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@

namespace Sonata\AdminBundle\Tests\Fixtures\Controller;

/**
* Some documentation about Bar controller.
*/
class BarAdminController
{
/**
* Bar action.
*/
public function barAction(): void
{
}
Expand Down
6 changes: 0 additions & 6 deletions tests/Fixtures/Controller/FooAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@

namespace Sonata\AdminBundle\Tests\Fixtures\Controller;

/**
* Some documentation about Foo controller.
*/
class FooAdminController extends AbstractFooAdminController
{
/**
* Foo action.
*/
public function fooAction($baz): void
{
}
Expand Down
3 changes: 3 additions & 0 deletions tests/Fixtures/Entity/Form/FooEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

class FooEntity
{
/**
* @var array
*/
private $values;

public function __construct(array $values = [])
Expand Down
9 changes: 9 additions & 0 deletions tests/Fixtures/TestExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@

class TestExtension implements FormExtensionInterface
{
/**
* @var array
*/
private $types = [];

/**
* @var array
*/
private $extensions = [];

/**
* @var FormTypeGuesserInterface|null
*/
private $guesser;

public function __construct(?FormTypeGuesserInterface $guesser)
Expand Down

0 comments on commit 5d69f28

Please sign in to comment.