Example #1
0
 /**
  * test requireParamsFromMap() method
  *
  * @test
  */
 public function requireParamsFromMap()
 {
     $this->generateComponent(['mocks' => ['request' => ['is']]]);
     $this->request->expects($this->any())->method('is')->with('get')->will($this->returnValue(true));
     $this->Api->recordMap = ['User' => ['id', 'name', 'email']];
     try {
         $this->Api->requireParamsFromMap();
         $this->fail('Expected LackParametersException was not thrown');
     } catch (PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (Exception $e) {
         $this->assertInstanceOf('LackParametersException', $e);
         $this->assertSame('id, name, email', $e->getMessage());
     }
     $this->request->query = ['id' => 1, 'name' => 'hiromi'];
     try {
         $this->Api->requireParamsFromMap();
         $this->fail('Expected LackParametersException was not thrown');
     } catch (PHPUnit_Framework_AssertionFailedError $e) {
         throw $e;
     } catch (Exception $e) {
         $this->assertInstanceOf('LackParametersException', $e);
         $this->assertSame('email', $e->getMessage());
     }
     $this->request->query['email'] = '*****@*****.**';
     $result = $this->Api->requireParamsFromMap();
     $this->assertSame(['id' => 1, 'name' => 'hiromi', 'email' => '*****@*****.**'], $result);
 }