Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2492 - Groups filtering & retrieve single endpoint #3084

Merged
merged 17 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reverted name filter for groups
  • Loading branch information
MatusMak committed Oct 12, 2021
commit d0e24e8a214f7c688e12a1d9a332afb95998266c
1 change: 0 additions & 1 deletion src/Filter/FilterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public function register()
],
GroupFilterer::class => [
GroupQuery\HiddenFilterGambit::class,
GroupQuery\NameFilterGambit::class,
],
PostFilterer::class => [
PostFilter\AuthorFilter::class,
Expand Down
72 changes: 0 additions & 72 deletions src/Group/Query/NameFilterGambit.php

This file was deleted.

85 changes: 5 additions & 80 deletions tests/integration/api/groups/ListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,82 +146,6 @@ public function hides_hidden_groups_when_filtering_for_guest()
$this->assertEquals([], Arr::pluck($data['data'], 'id'));
}

/**
* @test
*/
public function filters_groups_by_single_name()
{
$response = $this->send(
$this->request('GET', '/api/groups')
->withQueryParams([
'filter' => ['name' => 'Admin'],
])
);

$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true);

// Only admin group
$this->assertEquals(['1'], Arr::pluck($data['data'], 'id'));
}

/**
* @test
*/
public function filters_groups_by_single_name_negated()
{
$response = $this->send(
$this->request('GET', '/api/groups')
->withQueryParams([
'filter' => ['-name' => 'Admin'],
])
);

$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true);

// ALl public groups but admin
$this->assertEquals(['2', '3', '4'], Arr::pluck($data['data'], 'id'));
}

/**
* @test
*/
public function filters_groups_by_multiple_names()
{
$response = $this->send(
$this->request('GET', '/api/groups')
->withQueryParams([
'filter' => ['name' => 'Admin,Mods'],
])
);

$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true);

// Only admin & mod group
$this->assertEquals(['1', '4'], Arr::pluck($data['data'], 'id'));
}

/**
* @test
*/
public function filters_groups_by_multiple_names_negated()
{
$response = $this->send(
$this->request('GET', '/api/groups')
->withQueryParams([
'filter' => ['-name' => 'Admin,Mods'],
])
);

$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true);

// ALl public groups but admin & mods
$this->assertEquals(['2', '3'], Arr::pluck($data['data'], 'id'));
}

/**
* @test
*/
Expand Down Expand Up @@ -249,16 +173,17 @@ public function paginates_groups_with_filter()
$response = $this->send(
$this->request('GET', '/api/groups')
->withQueryParams([
'filter' => ['-name' => 'Admin'],
'page' => ['limit' => '2', 'offset' => '2'],
'filter' => ['hidden' => 1],
'page' => ['limit' => '1', 'offset' => '1'],
])
);

$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true);

// Show second page of groups
$this->assertEquals(['4'], Arr::pluck($data['data'], 'id'));
// Show second page of groups. Because there is only one hidden group,
// second page should be empty.
$this->assertEmpty($data['data']);
}

/**
Expand Down