Permalink
Browse files

Adding resourceMap accessor test

  • Loading branch information...
1 parent 8864805 commit 3eea2e207336e4eaf5b4bc33e48e1242e8f2931c @vesln vesln committed Jan 2, 2012
Showing with 31 additions and 0 deletions.
  1. +31 −0 lib/Cake/Test/Case/Routing/RouterTest.php
@@ -2454,6 +2454,37 @@ public function testPatternOnAction() {
$this->assertFalse($result);
}
+/**
+ * Tests resourceMap as getter and setter.
+ *
+ * @return void
+ */
+ public function testResourceMap() {
+ $default = Router::resourceMap();
+ $exepcted = array(
+ array('action' => 'index', 'method' => 'GET', 'id' => false),
+ array('action' => 'view', 'method' => 'GET', 'id' => true),
+ array('action' => 'add', 'method' => 'POST', 'id' => false),
+ array('action' => 'edit', 'method' => 'PUT', 'id' => true),
+ array('action' => 'delete', 'method' => 'DELETE', 'id' => true),
+ array('action' => 'edit', 'method' => 'POST', 'id' => true)
+ );
+ $this->assertEquals($default, $exepcted);
+
+ $custom = array(
+ array('action' => 'index', 'method' => 'GET', 'id' => false),
+ array('action' => 'view', 'method' => 'GET', 'id' => true),
+ array('action' => 'add', 'method' => 'POST', 'id' => false),
+ array('action' => 'edit', 'method' => 'PUT', 'id' => true),
+ array('action' => 'delete', 'method' => 'DELETE', 'id' => true),
+ array('action' => 'update', 'method' => 'POST', 'id' => true)
+ );
+ Router::resourceMap($custom);
+ $this->assertEquals($custom, Router::resourceMap());
+
+ Router::resourceMap($default);
+ }
+
/**
* test setting redirect routes
*

0 comments on commit 3eea2e2

Please sign in to comment.