Skip to content

Commit

Permalink
Fix tests and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed Feb 20, 2014
1 parent 00053cd commit eb9a29b
Show file tree
Hide file tree
Showing 25 changed files with 16 additions and 243 deletions.
9 changes: 1 addition & 8 deletions src/ZfrRest/Factory/PostHandlerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ public function createService(ServiceLocatorInterface $serviceLocator)
{
$parentLocator = $serviceLocator->getServiceLocator();

/* @var \ZfrRest\Options\ModuleOptions $options */
$options = $parentLocator->get('ZfrRest\Options\ModuleOptions');

return new PostHandler(
$options->getControllerBehaviours(),
$parentLocator->get('InputFilterManager'),
$parentLocator->get('HydratorManager')
);
return new PostHandler($parentLocator->get('InputFilterManager'), $parentLocator->get('HydratorManager'));
}
}
9 changes: 1 addition & 8 deletions src/ZfrRest/Factory/PutHandlerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ public function createService(ServiceLocatorInterface $serviceLocator)
{
$parentLocator = $serviceLocator->getServiceLocator();

/* @var \ZfrRest\Options\ModuleOptions $options */
$options = $parentLocator->get('ZfrRest\Options\ModuleOptions');

return new PutHandler(
$options->getControllerBehaviours(),
$parentLocator->get('InputFilterManager'),
$parentLocator->get('HydratorManager')
);
return new PutHandler($parentLocator->get('InputFilterManager'), $parentLocator->get('HydratorManager'));
}
}
2 changes: 1 addition & 1 deletion src/ZfrRest/Mvc/Controller/AbstractRestfulController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
use ZfrRest\Http\Exception\Client\NotFoundException;
use ZfrRest\Mvc\Controller\MethodHandler\MethodHandlerPluginManager;
use ZfrRest\Mvc\Exception\RuntimeException;
use ZfrRest\Resource\ResourceInterface;
use ZfrRest\Resource\Metadata\ResourceMetadataInterface;
use ZfrRest\Resource\ResourceInterface;
use ZfrRest\View\Model\ResourceModel;

/**
Expand Down
1 change: 0 additions & 1 deletion src/ZfrRest/Mvc/Controller/MethodHandler/DeleteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

namespace ZfrRest\Mvc\Controller\MethodHandler;

use Zend\Mvc\Controller\AbstractController;
use ZfrRest\Http\Exception\Client\MethodNotAllowedException;
use ZfrRest\Mvc\Controller\AbstractRestfulController;
use ZfrRest\Resource\ResourceInterface;
Expand Down
1 change: 0 additions & 1 deletion src/ZfrRest/Mvc/Controller/MethodHandler/GetHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

namespace ZfrRest\Mvc\Controller\MethodHandler;

use Zend\Mvc\Controller\AbstractController;
use ZfrRest\Http\Exception\Client\MethodNotAllowedException;
use ZfrRest\Mvc\Controller\AbstractRestfulController;
use ZfrRest\Resource\ResourceInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

namespace ZfrRest\Mvc\Controller\MethodHandler;

use Zend\Mvc\Controller\AbstractController;
use ZfrRest\Mvc\Controller\AbstractRestfulController;
use ZfrRest\Resource\ResourceInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

namespace ZfrRest\Mvc\Controller\MethodHandler;

use Zend\Mvc\Controller\AbstractController;
use ZfrRest\Mvc\Controller\AbstractRestfulController;
use ZfrRest\Resource\ResourceInterface;

Expand Down
5 changes: 0 additions & 5 deletions src/ZfrRest/Mvc/Controller/MethodHandler/PostHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
namespace ZfrRest\Mvc\Controller\MethodHandler;

use Zend\InputFilter\InputFilterPluginManager;
use Zend\Mvc\Controller\AbstractController;
use Zend\Stdlib\Hydrator\HydratorPluginManager;
use ZfrRest\Http\Exception\Client\MethodNotAllowedException;
use ZfrRest\Mvc\Controller\AbstractRestfulController;
use ZfrRest\Options\ControllerBehavioursOptions;
use ZfrRest\Resource\ResourceInterface;
use ZfrRest\View\Model\ResourceModel;

Expand Down Expand Up @@ -71,9 +69,6 @@ public function __construct(
* As you can see, the post method have three arguments: the object that is inserted, the resource metadata and
* the resource itself (which is the Collection where the object is added)
*
* Note that if you have set "auto_validate" and/or "auto_hydrate" to false in ZfrRest config, those steps will
* do nothing
*
* {@inheritDoc}
* @throws MethodNotAllowedException
*/
Expand Down
3 changes: 0 additions & 3 deletions src/ZfrRest/Mvc/Controller/MethodHandler/PutHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ public function __construct(
* - we hydrate valid data to update existing resource
* - we pass the object to the put method of the controller
*
* Note that if you have set "auto_validate" and/or "auto_hydrate" to false in ZfrRest config, those steps will
* do nothing
*
* {@inheritDoc}
* @throws MethodNotAllowedException
*/
Expand Down
1 change: 0 additions & 1 deletion src/ZfrRest/Mvc/Controller/Plugin/PaginatorWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Doctrine\Common\Collections\Selectable;
use DoctrineModule\Paginator\Adapter\Collection as CollectionAdapter;
use DoctrineModule\Paginator\Adapter\Selectable as SelectableAdapter;
use Traversable;
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
use Zend\Paginator\Paginator;
use ZfrRest\Exception\RuntimeException;
Expand Down
29 changes: 0 additions & 29 deletions src/ZfrRest/Options/ModuleOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

namespace ZfrRest\Options;

use Traversable;
use Zend\Stdlib\AbstractOptions;

/**
Expand Down Expand Up @@ -48,13 +47,6 @@ class ModuleOptions extends AbstractOptions
*/
protected $cache;

/**
* Controller behaviours
*
* @var ControllerBehavioursOptions|null
*/
protected $controllerBehaviours;

/**
* Array that map a custom exception to a HttpExceptionInterface exception
*
Expand Down Expand Up @@ -135,27 +127,6 @@ public function getCache()
return $this->cache;
}

/**
* @param array $controllerBehaviours
* @return void
*/
public function setControllerBehaviours(array $controllerBehaviours)
{
$this->controllerBehaviours = new ControllerBehavioursOptions($controllerBehaviours);
}

/**
* @return ControllerBehavioursOptions
*/
public function getControllerBehaviours()
{
if (null === $this->controllerBehaviours) {
$this->controllerBehaviours = new ControllerBehavioursOptions();
}

return $this->controllerBehaviours;
}

/**
* @param array $exceptionMap
* @return void
Expand Down
2 changes: 1 addition & 1 deletion src/ZfrRest/Resource/Metadata/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory;
use Metadata\Driver\DriverInterface;
use ReflectionClass;
use ZfrRest\Resource\Metadata\Annotation;
use ZfrRest\Resource\Metadata\CollectionResourceMetadata;
use ZfrRest\Resource\Metadata\ResourceMetadata;
use ZfrRest\Resource\Metadata\Annotation;

/**
* This driver loads the metadata from annotations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Selectable;
use Traversable;
use ZfrRest\Router\Exception\RuntimeException;
use ZfrRest\Resource\Resource;
use ZfrRest\Resource\ResourceInterface;
use ZfrRest\Router\Exception\RuntimeException;

/**
* Matcher for an collection sub-path
Expand Down
2 changes: 1 addition & 1 deletion src/ZfrRest/Router/Http/ResourceGraphRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
use Zend\EventManager\EventManagerAwareInterface;
use Zend\EventManager\EventManagerAwareTrait;
use Zend\Http\Request as HttpRequest;
use Zend\Mvc\Router\Http\RouteMatch;
use Zend\Mvc\Router\Http\RouteInterface;
use Zend\Mvc\Router\Http\RouteMatch;
use Zend\Stdlib\RequestInterface;
use ZfrRest\Resource\Resource;
use ZfrRest\Resource\ResourceInterface;
Expand Down
1 change: 0 additions & 1 deletion src/ZfrRest/View/Model/ResourceModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
namespace ZfrRest\View\Model;

use Zend\View\Model\ViewModel;
use ZfrRest\Resource\Metadata\ResourceMetadataInterface;
use ZfrRest\Resource\ResourceInterface;

/**
Expand Down
25 changes: 3 additions & 22 deletions tests/ZfrRestTest/Asset/Mvc/DataHydrationObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,10 @@ class DataHydrationObject
use DataHydrationTrait;

/**
* @var ControllerBehavioursOptions
* @param HydratorPluginManager $hydratorPluginManager
*/
protected $controllerBehavioursOptions;

/**
* @param ControllerBehavioursOptions $behavioursOptions
* @param HydratorPluginManager $hydratorPluginManager
*/
public function __construct(
ControllerBehavioursOptions $behavioursOptions,
HydratorPluginManager $hydratorPluginManager
) {
$this->controllerBehavioursOptions = $behavioursOptions;
$this->hydratorPluginManager = $hydratorPluginManager;
}

/**
* Get the controller behaviour options
*
* @return ControllerBehavioursOptions
*/
public function getControllerBehavioursOptions()
public function __construct(HydratorPluginManager $hydratorPluginManager)
{
return $this->controllerBehavioursOptions;
$this->hydratorPluginManager = $hydratorPluginManager;
}
}
23 changes: 2 additions & 21 deletions tests/ZfrRestTest/Asset/Mvc/DataValidationObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,17 @@

use Zend\InputFilter\InputFilterPluginManager;
use ZfrRest\Mvc\Controller\MethodHandler\DataValidationTrait;
use ZfrRest\Options\ControllerBehavioursOptions;

class DataValidationObject
{
use DataValidationTrait;

/**
* @var ControllerBehavioursOptions
*/
protected $controllerBehavioursOptions;

/**
* @param ControllerBehavioursOptions $behavioursOptions
* @param InputFilterPluginManager $inputFilterPluginManager
*/
public function __construct(
ControllerBehavioursOptions $behavioursOptions,
InputFilterPluginManager $inputFilterPluginManager
) {
$this->controllerBehavioursOptions = $behavioursOptions;
public function __construct(InputFilterPluginManager $inputFilterPluginManager)
{
$this->inputFilterPluginManager = $inputFilterPluginManager;
}

/**
* Get the controller behaviour options
*
* @return ControllerBehavioursOptions
*/
public function getControllerBehavioursOptions()
{
return $this->controllerBehavioursOptions;
}
}
2 changes: 0 additions & 2 deletions tests/ZfrRestTest/Factory/PostHandlerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use Zend\Stdlib\Hydrator\HydratorPluginManager;
use ZfrRest\Factory\PostHandlerFactory;
use ZfrRest\Mvc\Controller\MethodHandler\MethodHandlerPluginManager;
use ZfrRest\Options\ModuleOptions;

/**
* @licence MIT
Expand All @@ -42,7 +41,6 @@ public function testCreateFromFactory()
$pluginManager = new MethodHandlerPluginManager();
$pluginManager->setServiceLocator($serviceManager);

$serviceManager->setService('ZfrRest\Options\ModuleOptions', new ModuleOptions());
$serviceManager->setService('InputFilterManager', new InputFilterPluginManager());
$serviceManager->setService('HydratorManager', new HydratorPluginManager());

Expand Down
2 changes: 0 additions & 2 deletions tests/ZfrRestTest/Factory/PutHandlerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use Zend\Stdlib\Hydrator\HydratorPluginManager;
use ZfrRest\Factory\PutHandlerFactory;
use ZfrRest\Mvc\Controller\MethodHandler\MethodHandlerPluginManager;
use ZfrRest\Options\ModuleOptions;

/**
* @licence MIT
Expand All @@ -42,7 +41,6 @@ public function testCreateFromFactory()
$pluginManager = new MethodHandlerPluginManager();
$pluginManager->setServiceLocator($serviceManager);

$serviceManager->setService('ZfrRest\Options\ModuleOptions', new ModuleOptions());
$serviceManager->setService('InputFilterManager', new InputFilterPluginManager());
$serviceManager->setService('HydratorManager', new HydratorPluginManager());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,15 @@ class DataHydrationTraitTest extends PHPUnit_Framework_TestCase
*/
protected $dataHydration;

/**
* @var ControllerBehavioursOptions
*/
protected $controllerBehavioursOptions;

/**
* @var \Zend\Stdlib\Hydrator\HydratorPluginManager
*/
protected $hydratorPluginManager;

public function setUp()
{
$this->controllerBehavioursOptions = new ControllerBehavioursOptions();
$this->hydratorPluginManager = $this->getMock('Zend\Stdlib\Hydrator\HydratorPluginManager');

$this->dataHydration = new DataHydrationObject(
$this->controllerBehavioursOptions,
$this->hydratorPluginManager
);
}

public function testReturnUntouchedDataIfDontAutoHydrate()
{
$this->controllerBehavioursOptions->setAutoHydrate(false);

$result = $this->dataHydration->hydrateData($this->getMock('ZfrRest\Resource\ResourceInterface'), ['foo']);

$this->assertEquals(['foo'], $result);
$this->hydratorPluginManager = $this->getMock('Zend\Stdlib\Hydrator\HydratorPluginManager');
$this->dataHydration = new DataHydrationObject($this->hydratorPluginManager);
}

public function testThrowExceptionIfNoHydratorNameIsDefined()
Expand Down
Loading

0 comments on commit eb9a29b

Please sign in to comment.