public function testUserFilters()
 {
     $filterName = 'filter ' . uniqid();
     $writer = $this->client->getWriter(FUNCTIONAL_WRITER_ID);
     $this->assertArrayHasKey('gd', $writer);
     $this->assertArrayHasKey('pid', $writer['gd']);
     $result = $this->client->post('/gooddata-writer/filters', null, json_encode(['writerId' => FUNCTIONAL_WRITER_ID, 'pid' => $writer['gd']['pid'], 'name' => $filterName, 'attribute' => 'out.c-main.categories.name', 'value' => 'Category 1']))->send()->json();
     $this->assertArrayHasKey('url', $result);
     $jobResult = $this->client->waitForJob($result['url']);
     $this->assertArrayHasKey('status', $jobResult);
     $this->assertEquals('success', $jobResult['status']);
     $result = $this->client->get('/gooddata-writer/filters?writerId=' . FUNCTIONAL_WRITER_ID)->send()->json();
     $this->assertArrayHasKey('filters', $result);
     $filterFound = false;
     foreach ($result['filters'] as $f) {
         if ($f['name'] == $filterName) {
             $filterFound = true;
         }
     }
     $this->assertTrue($filterFound);
     $result = $this->client->post('/gooddata-writer/filters-users', null, json_encode(['writerId' => FUNCTIONAL_WRITER_ID, 'filters' => [$filterName], 'email' => $writer['gd']['username']]))->send()->json();
     $this->assertArrayHasKey('url', $result);
     $jobResult = $this->client->waitForJob($result['url']);
     $this->assertArrayHasKey('status', $jobResult);
     $this->assertEquals('success', $jobResult['status']);
     $result = $this->client->delete('/gooddata-writer/filters?writerId=' . FUNCTIONAL_WRITER_ID . '&name=' . $filterName)->send()->json();
     $this->assertArrayHasKey('url', $result);
     $jobResult = $this->client->waitForJob($result['url']);
     $this->assertArrayHasKey('status', $jobResult);
     $this->assertEquals('success', $jobResult['status']);
     $result = $this->client->get('/gooddata-writer/filters?writerId=' . FUNCTIONAL_WRITER_ID)->send()->json();
     $this->assertArrayHasKey('filters', $result);
     foreach ($result['filters'] as $f) {
         if ($f['name'] == $filterName) {
             $this->fail();
         }
     }
 }