Exemplo n.º 1
0
 /**
  * @depends testGet
  * @covers Phramework\LogJSONAPI\Models\SystemLog::getById
  */
 public function testGetById($id)
 {
     $data = SystemLog::getById($id);
     $this->assertNotNull($data);
     $this->assertInternalType('object', $data);
     $this->assertObjectHasAttribute('id', $data);
     $this->assertObjectHasAttribute('type', $data);
     $this->assertObjectHasAttribute('attributes', $data);
     $this->assertSame($id, $data->id);
 }
Exemplo n.º 2
0
 /**
  * Return only ids
  * @param  string $systemLogId Foreign key
  * @return string[]
  */
 public static function getRelationshipBySystemLog($systemLogId)
 {
     //Access system log object by this id to get the request_id
     $systemLogObject = SystemLog::getById($systemLogId);
     if (!$systemLogObject) {
         return [];
     }
     $requestId = $systemLogObject->attributes->request_id;
     QueryLogAdapter::prepare();
     $table = static::$table = QueryLogAdapter::getTable();
     $schema = QueryLogAdapter::getSchema();
     //Include schema if is set at current QueryLog database adapter
     $schema = $schema ? sprintf('"%s".', $schema) : '';
     $ids = QueryLogAdapter::executeAndFetchAllArray(sprintf('SELECT "id"
             FROM %s"%s"
             WHERE "request_id" = ?', $schema, $table), [$requestId]);
     return array_map('strval', $ids);
 }