public function testFetchAccessTokens()
 {
     $tempCredentials = new ehough_coauthor_api_v1_Credentials('a', 'b');
     $this->_mockHttpClient->shouldReceive('execute')->once()->with(ehough_mockery_Mockery::on(array($this, '__callbackFetchTokensHttpRequest')))->andReturn($this->_mockHttpResponse);
     $this->_mockSigner->shouldReceive('signForAccessTokenRequest')->once()->with(ehough_mockery_Mockery::on(array($this, '__callbackFetchTokensHttpRequest')), $this->_mockClientCredentials, $tempCredentials, 'some-code');
     $this->_mockServer->shouldReceive('onCredentialsOrTokenRequest')->once()->with(ehough_mockery_Mockery::on(array($this, '__callbackFetchTokensHttpRequest')));
     $this->_mockServer->shouldReceive('onAfterCredentialsOrTokenRequest')->once()->with(ehough_mockery_Mockery::on(array($this, '__callbackFetchTokensHttpRequest')), $this->_mockHttpResponse);
     $result = $this->_sut->fetchToken($this->_mockClientCredentials, $this->_mockServer, $tempCredentials, 'some-code');
     $this->assertEquals('token', $result->getIdentifier());
 }
Ejemplo n.º 2
0
 public function testCanOverrideExpectedParametersOfInternalPHPClassesToPreserveRefs()
 {
     if (!class_exists('MongoCollection', false)) {
         $this->markTestSkipped('ext/mongo not installed');
     }
     ehough_mockery_Mockery::getConfiguration()->setInternalClassMethodParamMap('MongoCollection', 'insert', array('&$data', '$options'));
     $m = $this->container->mock('MongoCollection');
     $m->shouldReceive('insert')->with(ehough_mockery_Mockery::on(function (&$data) {
         $data['_id'] = 123;
         return true;
     }), ehough_mockery_Mockery::type('array'));
     $data = array('a' => 1, 'b' => 2);
     $m->insert($data, array());
     $this->assertTrue(isset($data['_id']));
     $this->assertEquals(123, $data['_id']);
     $this->container->mockery_verify();
     ehough_mockery_Mockery::resetContainer();
 }
Ejemplo n.º 3
0
 /**
  * @expectedException ehough_mockery_mockery_Exception
  */
 public function testOnConstraintThrowsExceptionWhenConstraintUnmatched_ClosureEvaluatesToFalse()
 {
     $function = function ($arg) {
         return $arg % 2 == 0;
     };
     $this->mock->shouldReceive('foo')->with(ehough_mockery_Mockery::on($function))->once();
     $this->mock->foo(5);
     $this->container->mockery_verify();
 }