Example #1
0
 /**
  * test requireParams() method
  *
  * @test
  */
 public function requireParams()
 {
     $this->generateComponent(['mocks' => ['Api' => ['collectParams']]]);
     $this->Api->expects($this->once())->method('collectParams')->with(['test'])->will($this->returnValue(['test' => 'testValue']));
     $result = $this->Api->requireParams(['test']);
     $this->assertSame(['test' => 'testValue'], $result);
     $this->generateComponent(['mocks' => ['Api' => ['collectParams']]]);
     $this->Api->expects($this->once())->method('collectParams')->with(['test'])->will($this->returnValue(['test2' => 'testValue2']));
     try {
         $this->Api->requireParams(['test']);
         $this->fail('Expected LackParametersException was not thrown');
     } catch (Exception $e) {
         $this->assertInstanceOf('LackParametersException', $e);
         $this->assertSame('test', $e->getMessage());
     }
 }