/** * Only create a factory mock here - hopefully this can be used somewhere else * @param mixed $ret Anything that should be returned by the mocked Request object * @return Nyx\Factory */ protected function _getFactoryRequestMock($ret = '') { $request_stub = new HttpfulRequestStub(); $request_stub->setReturn($ret); $factory_mock = $this->getMock('Nyx\\Factory'); $factory_mock->expects($this->any())->method('request')->will($this->returnValue($request_stub)); return $factory_mock; }
/** * @test */ public function invalidJsonResponseReturnsArray() { $request_stub = new HttpfulRequestStub(); $request_stub->setReturn('invalid json'); $factory_mock = $this->getMock('Nyx\\Factory'); $factory_mock->expects($this->any())->method('request')->will($this->returnValue($request_stub)); $instance = new OpenCalais(); $instance->setFactory($factory_mock); $val = $instance->enrich('this may or may not be a wall of text'); $this->assertEmpty($val); $this->assertInternalType('array', $val); }