Example #1
0
 /**
  * @covers \lapistano\wsunit\Http\HttpClient::getResponseObject
  */
 public function testGetResponseObjectFromCache()
 {
     $pb = new ProxyBuilder('\\lapistano\\wsunit\\Http\\HttpClient');
     $client = $pb->setProperties(array('response'))->getProxy();
     $client->response = new \stdClass();
     $this->assertInternalType('object', $client->getResponseObject());
 }
Example #2
0
 public function testLibraryHook()
 {
     $client = new SoapClient(self::WSDL);
     $proxy = new ProxyBuilder('\\VCR\\Util\\SoapClient');
     $client = $proxy->disableOriginalConstructor()->setMethods(array('getLibraryHook'))->getProxy();
     $this->assertInstanceOf('\\VCR\\LibraryHooks\\SoapHook', $client->getLibraryHook());
     $client->setLibraryHook($this->getLibraryHookMock(true));
     $this->assertInstanceOf('\\VCR\\LibraryHooks\\SoapHook', $client->getLibraryHook());
 }
Example #3
0
 public function testHandleRequestRecordsRequest()
 {
     $request = new Request('GET', 'http://example.com', array('User-Agent' => 'Unit-Test'));
     $response = new Response(200, array(), 'example response');
     $client = $this->getClientMock($request, $response);
     $configuration = new Configuration();
     $configuration->enableLibraryHooks(array());
     $proxy = new ProxyBuilder('\\VCR\\Videorecorder');
     $videorecorder = $proxy->setConstructorArgs(array($configuration, $client, VCRFactory::getInstance()))->setProperties(array('cassette', 'client'))->getProxy();
     $videorecorder->client = $client;
     $videorecorder->cassette = $this->getCassetteMock($request, $response);
     $this->assertEquals($response, $videorecorder->handleRequest($request));
 }
 public function testGetInstanceOf()
 {
     $proxyBuilder = new ProxyBuilder('\\lapistano\\ProxyObject\\ProxyBuilder');
     $proxy = $proxyBuilder->disableOriginalConstructor()->setMethods(array('getInstanceOf'))->getProxy();
     $this->assertInstanceOf('stdClass', $proxy->getInstanceOf('stdClass'));
 }
Example #5
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->testRecord = $this->getMockBuilder("\\Graviton\\RestBundle\\Model\\RecordOriginInterface")->setMethods(["isRecordOriginModifiable", "getRecordOrigin"])->getMock();
     $proxyBuilder = new ProxyBuilder("\\Graviton\\RestBundle\\Model\\DocumentModel");
     $this->sut = $proxyBuilder->disableOriginalConstructor()->setProperties(array('notModifiableOriginRecords'))->setMethods(['checkIfOriginRecord'])->getProxy();
 }
Example #6
0
 /**
  * @covers \lapistano\wsunit\Http\HttpClient::getResponseObject
  */
 public function testGetResponseObject()
 {
     $pb = new ProxyBuilder('\\lapistano\\wsunit\\Http\\HttpClient');
     $client = $pb->setMethods(array('getResponseObject'))->getProxy();
     $this->assertInstanceOf('\\lapistano\\wsunit\\Http\\HttpResponse', $client->getResponseObject());
 }
 /**
  * @dataProvider codeSnippetProvider
  */
 public function testTransformCode($expected, $code)
 {
     $proxy = new ProxyBuilder('\\VCR\\CodeTransform\\CurlCodeTransform');
     $filter = $proxy->setMethods(array('transformCode'))->getProxy();
     $this->assertEquals($expected, $filter->transformCode($code));
 }
 /**
  * @expectedException \lapistano\ProxyObject\GeneratorException
  */
 public function testGetProxyOfClassWithStaticProtectedMethod()
 {
     $proxy = new ProxyBuilder('\\DummyWithNoProxyableProtectedMethods');
     $proxiedClass = $proxy->getProxy();
 }