get() public method

Returns the definition string.
public get ( ) : string
return string The definition.
Exemplo n.º 1
0
 public function testGetDPUBreakdownOnInvalidDefinition()
 {
     $def = new DataSift_Definition($this->user, testdata('invalid_definition'));
     $this->assertEquals($def->get(), testdata('invalid_definition'));
     $response = array('response_code' => 400, 'data' => array('error' => 'The target interactin.content does not exist'), 'rate_limit' => 200, 'rate_limit_remaining' => 150);
     DataSift_MockApiClient::setResponse($response);
     try {
         $def->getDPUBreakdown();
         $this->fail('CompileFailed exception expected, but not thrown');
     } catch (DataSift_Exception_InvalidData $e) {
         // Check the error message
         $this->assertEquals($e->getMessage(), $response['data']['error']);
     } catch (DataSift_Exception_APIError $e) {
         $this->fail('APIError: ' . $e->getMessage() . ' (' . $e->getCode() . ')');
     } catch (Exception $e) {
         $this->fail('Unhandled exception: ' . $e->getMessage() . ' (' . $e->getCode() . ')');
     }
 }
Exemplo n.º 2
0
 public function testGetBuffered()
 {
     $def = new DataSift_Definition($this->user, testdata('definition'));
     $response = array('response_code' => 200, 'data' => array('hash' => testdata('definition_hash'), 'created_at' => date('Y-m-d H:i:s', time()), 'dpu' => 10), 'rate_limit' => 200, 'rate_limit_remaining' => 150);
     DataSift_MockApiClient::setResponse($response);
     $this->assertEquals($def->get(), testdata('definition'), 'Definition string not set correctly');
     $response = array('response_code' => 200, 'data' => array('stream' => array('Test interaction 1', 'Test interaction 2'), 'hash' => testdata('definition_hash'), 'created_at' => date('Y-m-d H:i:s', time()), 'dpu' => 10), 'rate_limit' => 200, 'rate_limit_remaining' => 150);
     DataSift_MockApiClient::setResponse($response);
     $interactions = $def->getBuffered();
     $this->assertTrue(is_array($interactions), 'Failed to get buffered interactions');
 }