Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed Tests

  • Loading branch information...
commit 5428eafa0fb3b4662442d8064addd748d7f44552 1 parent bff73c6
@Hounddog authored
View
3  README.md
@@ -35,6 +35,9 @@ Copy the These files
* `module/Album/config/database.local.php.dist` to `config/autload/database.local.php`
* `module/Album/config/global.php.dist` to `config/autload/global.php`
+###Database Setup
+Import module/Album/data/album.sql into your database
+
###Usage
Browser to the album page
View
16 data/album.sql
@@ -0,0 +1,16 @@
+CREATE TABLE album (
+ id int(11) NOT NULL auto_increment,
+ artist varchar(100) NOT NULL,
+ title varchar(100) NOT NULL,
+ PRIMARY KEY (id)
+);
+INSERT INTO album (artist, title)
+ VALUES ('The Military Wives', 'In My Dreams');
+INSERT INTO album (artist, title)
+ VALUES ('Adele', '21');
+INSERT INTO album (artist, title)
+ VALUES ('Bruce Springsteen', 'Wrecking Ball (Deluxe)');
+INSERT INTO album (artist, title)
+ VALUES ('Lana Del Rey', 'Born To Die');
+INSERT INTO album (artist, title)
+ VALUES ('Gotye', 'Making Mirrors');
View
23 test/AlbumTest/Controller/AlbumControllerTest.php
@@ -9,7 +9,7 @@
use Zend\Mvc\Router\RouteMatch;
use PHPUnit_Framework_TestCase;
use AlbumTest\Bootstrap;
-
+use Zend\Mvc\Router\Http\TreeRouteStack as HttpRouter;
class AlbumControllerTest extends PHPUnit_Framework_TestCase
{
protected $controller;
@@ -20,15 +20,24 @@ class AlbumControllerTest extends PHPUnit_Framework_TestCase
protected function setUp()
{
+ $serviceManager = Bootstrap::getServiceManager();
+
$this->controller = new AlbumController();
$this->request = new Request();
$this->routeMatch = new RouteMatch(array('controller' => 'index'));
$this->event = new MvcEvent();
+
+ $config = $serviceManager->get('Config');
+ $routerConfig = isset($config['router']) ? $config['router'] : array();
+ $router = HttpRouter::factory($routerConfig);
+
+ $this->event->setRouter($router);
$this->event->setRouteMatch($this->routeMatch);
$this->controller->setEvent($this->event);
- $this->controller->setServiceLocator(Bootstrap::getServiceManager());
+ $this->controller->setServiceLocator($serviceManager);
}
+
public function testAddActionCanBeAccessed()
{
$this->routeMatch->setParam('action', 'add');
@@ -40,22 +49,20 @@ public function testAddActionCanBeAccessed()
public function testDeleteActionCanBeAccessed()
{
- $this->routeMatch->setParam('action', 'delete');
+ $this->routeMatch->setParam('action', 'edit');
$result = $this->controller->dispatch($this->request);
$response = $this->controller->getResponse();
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals(302, $response->getStatusCode());
}
- public function testEditActionCanBeAccessed()
+ public function testEditActionCanBeAccessed()
{
$this->routeMatch->setParam('action', 'edit');
-
$result = $this->controller->dispatch($this->request);
$response = $this->controller->getResponse();
-
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals(302, $response->getStatusCode());
}
public function testIndexActionCanBeAccessed()
View
11 test/Bootstrap.php
@@ -13,6 +13,8 @@
class Bootstrap
{
protected static $serviceManager;
+ protected static $config;
+ protected static $bootstrap;
public static function init()
{
@@ -51,7 +53,9 @@ public static function init()
$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', $config);
$serviceManager->get('ModuleManager')->loadModules();
+
static::$serviceManager = $serviceManager;
+ static::$config = $config;
}
public static function getServiceManager()
@@ -59,6 +63,13 @@ public static function getServiceManager()
return static::$serviceManager;
}
+ public static function getConfig()
+ {
+ return static::$config;
+ }
+
+
+
protected static function initAutoloader()
{
$vendorPath = static::findParentPath('vendor');
Please sign in to comment.
Something went wrong with that request. Please try again.