public function runAndTestReport($uploadId = 1) { list($success, $output, $retCode) = $this->runnerCli->run($uploadId, $this->userId, $this->groupId, $jobId = 7); assertThat('cannot run runner', $success, equalTo(true)); assertThat('report failed: "' . $output . '"', $retCode, equalTo(0)); assertThat($this->getHeartCount($output), greaterThan(0)); $row = $this->dbManager->getSingleRow("SELECT upload_fk,job_fk,filepath FROM reportgen WHERE job_fk = \$1", array($jobId), "reportFileName"); assertThat($row, hasKeyValuePair('upload_fk', $uploadId)); assertThat($row, hasKeyValuePair('job_fk', $jobId)); $filepath = $row['filepath']; assertThat($filepath, endsWith('.rdf')); assertThat(file_exists($filepath), equalTo(true)); $copyrightStatement = '*****@*****.**'; assertThat(file_get_contents($filepath), stringContainsInOrder($copyrightStatement)); $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount() - $this->assertCountBefore); $this->verifyRdf($filepath); unlink($filepath); $this->rmRepo(); }
public function testAcceptsVariableArguments() { $this->assertMatches(stringContainsInOrder('a', 'b', 'c'), 'abc', 'substrings as variable arguments'); }
/** * @test * @expectedException Crunch\Salesforce\Exceptions\RequestException * @expectedExceptionMessage expired authorization code */ public function client_can_parse_auth_flow_error() { //Error Response $errorResponse = m::mock('Psr\\Http\\Message\\ResponseInterface'); $errorResponse->shouldReceive('getBody')->once()->andReturn('{"error_description":"expired authorization code","error":"invalid_grant"}'); $errorResponse->shouldReceive('getStatusCode')->once()->andReturn(400); //Make guzzle throw an exception with the above message $guzzle = m::mock('\\GuzzleHttp\\Client'); $guzzleException = m::mock('GuzzleHttp\\Exception\\RequestException'); $guzzleException->shouldReceive('getResponse')->andReturn($errorResponse); //Make sure the url contains the passed in data $guzzle->shouldReceive('post')->with(stringContainsInOrder('services/oauth2/token'), \Mockery::type('array'))->once()->andThrow($guzzleException); //Setup the client $sfClient = new \Crunch\Salesforce\Client($this->getClientConfigMock(), $guzzle); $sfClient->setAccessToken($this->getAccessTokenMock()); //Try the auth flow - this should generate an exception $sfClient->authorizeConfirm('authCode', 'redirectUrl'); }