/** * test writing request params with param() * * @return void */ public function testParamWriting() { $request = new CakeRequest('/'); $request->addParams(array('action' => 'index')); $this->assertInstanceOf('CakeRequest', $request->param('some', 'thing'), 'Method has not returned $this'); $request->param('Post.null', null); $this->assertNull($request->params['Post']['null']); $request->param('Post.false', false); $this->assertFalse($request->params['Post']['false']); $request->param('Post.zero', 0); $this->assertSame(0, $request->params['Post']['zero']); $request->param('Post.empty', ''); $this->assertSame('', $request->params['Post']['empty']); $this->assertSame('index', $request->action); $request->param('action', 'edit'); $this->assertSame('edit', $request->action); }
/** * Test using param() * * @return void */ public function testReadingParams() { $request = new CakeRequest(); $request->addParams(array('controller' => 'posts', 'admin' => true, 'truthy' => 1, 'zero' => '0')); $this->assertFalse($request->param('not_set')); $this->assertTrue($request->param('admin')); $this->assertEquals(1, $request->param('truthy')); $this->assertEquals('posts', $request->param('controller')); $this->assertEquals('0', $request->param('zero')); }