Permalink
Browse files

Merge pull request #20 from GeometriaLab/feature/controllerTests

Remove CleanupDatabases plugin.
  • Loading branch information...
2 parents dc96042 + aec9a89 commit a14f92d37a9d898b9b174fe3e363c6a54f82b191 @shumkov shumkov committed Nov 26, 2012
@@ -4,15 +4,13 @@
use GeometriaLab\Model\ModelInterface,
GeometriaLab\Model\CollectionInterface,
- GeometriaLab\Model\Schema\SchemaInterface,
GeometriaLab\Api\Mvc\View\Model\ApiModel,
GeometriaLab\Api\Paginator\ModelPaginator,
- GeometriaLab\Api\Exception\InvalidFieldsException,
- GeometriaLab\Api\Mvc\Controller\Action\Params\AbstractParams,
- GeometriaLab\Api\Mvc\Controller\Action\Params\Schema\Property\IntegerProperty as ParamsIntegerProperty;
+ GeometriaLab\Api\Exception\InvalidFieldsException;
use Zend\Mvc\MvcEvent as ZendMvcEvent,
Zend\Mvc\View\Http\InjectViewModelListener as ZendInjectViewModelListener,
+ Zend\Http\PhpEnvironment\Response,
Zend\EventManager\ListenerAggregateInterface as ZendListenerAggregateInterface,
Zend\EventManager\EventManagerInterface as ZendEvents,
Zend\Validator\LessThan as ZendLessThanValidator,
@@ -78,9 +76,19 @@ public function createApiModel(ZendMvcEvent $e)
$apiModel->setVariable(ApiModel::FIELD_DATA, null);
}
+ /* @var Response $response */
$response = $e->getResponse();
$apiException = $e->getParam('apiException', false);
+ if ($response->getStatusCode() === Response::STATUS_CODE_200) {
+ if ($apiModel->getVariable(ApiModel::FIELD_DATA) === null) {
+ $response->setStatusCode(Response::STATUS_CODE_204);
+ }
+ if ($e->getRouteMatch()->getParam('action') === 'create') {
+ $response->setStatusCode(Response::STATUS_CODE_201);
+ }
+ }
+
// set http code
$httpCode = $response->getStatusCode();
$apiModel->setVariable(ApiModel::FIELD_HTTPCODE, $httpCode);
@@ -514,6 +514,16 @@ public function createQuery()
}
/**
+ * Get MongoCollection
+ *
+ * @return \MongoCollection
+ */
+ public function getMongoCollection()
+ {
+ return $this->getMongo()->selectCollection($this->getCollectionName());
+ }
+
+ /**
* Set Service Manager
*
* @param ZendServiceManager $serviceManager
@@ -565,14 +575,4 @@ protected function getMongo()
{
return self::$serviceManager->get('MongoManager')->get($this->getMongoInstanceName());
}
-
- /**
- * Get MongoCollection
- *
- * @return \MongoCollection
- */
- protected function getMongoCollection()
- {
- return $this->getMongo()->selectCollection($this->getCollectionName());
- }
}
@@ -37,7 +37,7 @@ public function getTest()
/**
* It will call when a test ended
*/
- public function tearDown()
+ public function endTest()
{
}
@@ -24,5 +24,5 @@ public function getTest();
/**
* It will call when a test ended
*/
- public function tearDown();
+ public function endTest();
}
@@ -121,8 +121,8 @@ public function endTest(\PHPUnit_Framework_Test $test, $time)
}
foreach ($plugins as $pluginName) {
$plugin = $test->getPluginManager()->get($pluginName);
- if (method_exists($plugin, 'tearDown')) {
- $plugin->tearDown();
+ if (method_exists($plugin, 'endTest')) {
+ $plugin->endTest();
}
}
}

0 comments on commit a14f92d

Please sign in to comment.