Skip to content

Commit

Permalink
Added ShowMapperTest, BaseMapperTest, BaseGroupedMapperTest
Browse files Browse the repository at this point in the history
Changed AdminInterface: added some new methods.
  • Loading branch information
pulzarraider committed Aug 29, 2013
1 parent 9d7591a commit 0c1c26b
Show file tree
Hide file tree
Showing 6 changed files with 340 additions and 20 deletions.
27 changes: 11 additions & 16 deletions Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -998,10 +998,10 @@ public function getActiveSubClass()
if (!$this->hasActiveSubClass()) {
return null;
}

return $this->getClass();
}

/**
* {@inheritdoc}
*/
Expand All @@ -1010,16 +1010,16 @@ public function getActiveSubclassCode()
if (!$this->hasActiveSubClass()) {
return null;
}

$subClass = $this->getRequest()->query->get('subclass');

if(! $this->hasSubClass($subClass)){
return null;
}

return $subClass;
}

/**
* Returns the list of batchs actions
*
Expand Down Expand Up @@ -1452,7 +1452,7 @@ public function setLabel($label)
}

/**
* @return string
* {@inheritdoc}
*/
public function getLabel()
{
Expand Down Expand Up @@ -1527,24 +1527,23 @@ public function reorderFormGroup($group, array $keys)
}

/**
* @return array
* {@inheritdoc}
*/
public function getShowGroups()
{
return $this->showGroups;
}

/**
* @param array $showGroups
* {@inheritdoc}
*/
public function setShowGroups(array $showGroups)
{
$this->showGroups = $showGroups;
}

/**
* @param string $group
* @param array $keys
* {@inheritdoc}
*/
public function reorderShowGroup($group, array $keys)
{
Expand Down Expand Up @@ -1712,11 +1711,7 @@ public function addShowFieldDescription($name, FieldDescriptionInterface $fieldD
}

/**
* remove a FieldDescription
*
* @param string $name
*
* @return void
* {@inheritdoc}
*/
public function removeShowFieldDescription($name)
{
Expand Down
39 changes: 37 additions & 2 deletions Admin/AdminInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ public function getRouterIdParameter();
*/
public function addShowFieldDescription($name, FieldDescriptionInterface $fieldDescription);

/**
* Remove a ShowFieldDescription
*
* @param string $name
*/
public function removeShowFieldDescription($name);

/**
* add a list FieldDescription
*
Expand Down Expand Up @@ -611,6 +618,28 @@ public function getFormGroups();
*/
public function setFormGroups(array $formGroups);

/**
* Returns the show groups
*
* @return array
*/
public function getShowGroups();

/**
* Set the show groups
*
* @param array $showGroups
*/
public function setShowGroups(array $showGroups);

/**
* Reorder items in showGroup
*
* @param string $group
* @param array $keys
*/
public function reorderShowGroup($group, array $keys);

/**
* add a FieldDescription
*
Expand Down Expand Up @@ -657,12 +686,18 @@ public function hasActiveSubClass();
* @return string the active sub class
*/
public function getActiveSubClass();

/**
* Returns the currently active sub class code
*
*
* @return string the code for active sub class
*/
public function getActiveSubclassCode();

/**
* Returns Admin`s label
*
* @return string
*/
public function getLabel();
}
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CHANGELOG
=========

### 2013-08-30
* [BC BREAK] added ``getLabel``, ``removeShowFieldDescription``, ``getShowGroups``,
``setShowGroups``, ``reorderShowGroup`` to the AdminInterface
If you do not extend the Admin class, you need to add these methods to
your admin.

### 2013-07-26

* [BC BREAK] added alterNewInstance to AdminExtensionInterface
Expand Down Expand Up @@ -117,14 +123,14 @@ CHANGELOG
* add country field type
* refactor the form creation

### 18/01/2011
### 2011-01-18

* respect symfony conventions
* add new base edit template (standard and inline)
* admin instances are not singletons anymore
* add inline edition

### 15/01/2011
### 2011-01-15

* respect symfony conventions
* add a FieldDescription
Expand Down
46 changes: 46 additions & 0 deletions Tests/Mapper/BaseGroupedMapperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/*
* This file is part of the Sonata 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\AdminBundle\Tests\Mapper;

use Sonata\AdminBundle\Mapper\BaseGroupedMapper;

/**
* Test for BaseGroupedMapper
*
* @author Andrej Hudec <[email protected]>
*/
class BaseGroupedMapperTest extends \PHPUnit_Framework_TestCase
{

/**
* @var BaseGroupedMapper
*/
protected $baseGroupedMapper;

public function setUp()
{
$admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
$builder = $this->getMock('Sonata\AdminBundle\Builder\BuilderInterface');

$this->baseGroupedMapper = $this->getMockForAbstractClass('Sonata\AdminBundle\Mapper\BaseGroupedMapper', array($builder, $admin));
}

public function testWith()
{
$this->assertEquals($this->baseGroupedMapper, $this->baseGroupedMapper->with('fooGroup'));
}

public function testEnd()
{
$this->assertEquals($this->baseGroupedMapper, $this->baseGroupedMapper->with('fooGroup'));
}
}
48 changes: 48 additions & 0 deletions Tests/Mapper/BaseMapperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/*
* This file is part of the Sonata 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\AdminBundle\Tests\Mapper;

use Sonata\AdminBundle\Admin\AdminInterface;
use Sonata\AdminBundle\Builder\BuilderInterface;
use Sonata\AdminBundle\Mapper\BaseMapper;

/**
* Test for BaseMapperTest
*
* @author Andrej Hudec <[email protected]>
*/
class BaseMapperTest extends \PHPUnit_Framework_TestCase
{
/**
* @var BaseMapper
*/
protected $baseMapper;

/**
* @var AdminInterface
*/
protected $admin;

public function setUp()
{
$this->admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
$builder = $this->getMock('Sonata\AdminBundle\Builder\BuilderInterface');

$this->baseMapper = $this->getMockForAbstractClass('Sonata\AdminBundle\Mapper\BaseMapper', array($builder, $this->admin));
}

public function testGetAdmin()
{
$this->assertEquals($this->admin, $this->baseMapper->getAdmin());
}
}
Loading

0 comments on commit 0c1c26b

Please sign in to comment.