Skip to content

Commit

Permalink
fix: remove team member test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CS76 committed Feb 3, 2024
1 parent f3ab2aa commit 485c06d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 41 deletions.
2 changes: 1 addition & 1 deletion app/Policies/TeamPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function updateTeamMember(User $user, Team $team)
*/
public function removeTeamMember(User $user, Team $team)
{
if ($user->hasTeamRole($user->currentTeam->fresh(), 'owner') || $user->ownsTeam($team)) {
if ($user->hasTeamRole($team, 'owner') || $user->ownsTeam($team)) {
return true;
} else {
return false;
Expand Down
2 changes: 1 addition & 1 deletion database/factories/CitationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function definition()
$author = $author1.', '.$author2;

return [
'doi' => "10.102X/acs.jnatprod.1c01SS",
'doi' => '10.102X/acs.jnatprod.1c01SS',
'title' => $this->faker->title(),
'authors' => $author,
'citation_text' => $this->faker->text(),
Expand Down
55 changes: 26 additions & 29 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
</include>
</coverage>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="pgsql"/>
<env name="DB_DATABASE" value="nmrxiv"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<coverage/>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="pgsql"/>
<env name="DB_DATABASE" value="nmrxiv"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
</php>
<source>
<include>
<directory suffix=".php">./app</directory>
</include>
</source>
</phpunit>
24 changes: 14 additions & 10 deletions tests/Feature/RemoveTeamMemberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@ public function test_team_members_can_be_removed_from_teams()
$this->assertCount(0, $user->currentTeam->fresh()->users);
}

/* public function test_only_team_owner_can_remove_team_members()
{
$user = User::factory()->withPersonalTeam()->create();
public function test_only_team_owner_can_remove_team_members()
{
$user = User::factory()->withPersonalTeam()->create();

$user->currentTeam->users()->attach(
$otherUser = User::factory()->create(), ['role' => 'collaborator']
);
$user->currentTeam->users()->attach(
$otherUser = User::factory()->withPersonalTeam()->create(), ['role' => 'collaborator']
);

$this->actingAs($otherUser);
$user->currentTeam->users()->attach(
$anotherUser = User::factory()->withPersonalTeam()->create(), ['role' => 'collaborator']
);

$this->actingAs($otherUser);

$response = $this->delete('/teams/'.$user->currentTeam->id.'/members/'.$user->id);
$response = $this->delete('/teams/'.$user->currentTeam->id.'/members/'.$anotherUser->id);

$response->assertStatus(403);
} */
$response->assertStatus(403);
}
}

1 comment on commit 485c06d

@CS76
Copy link
Member Author

@CS76 CS76 commented on 485c06d Feb 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes #1072

Please sign in to comment.