Skip to content

Commit

Permalink
fix test and run pint
Browse files Browse the repository at this point in the history
  • Loading branch information
temaotl committed Jul 15, 2024
1 parent 7d13e99 commit 3aa5ac3
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 45 deletions.
4 changes: 1 addition & 3 deletions tests/Feature/Http/Controllers/CategoryControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests\Feature\Http\Controllers;

use App\Jobs\EduGainAddEntity;
use App\Jobs\GitAddCategory;
use App\Jobs\GitDeleteCategory;
use App\Jobs\GitUpdateCategory;
Expand All @@ -11,8 +10,8 @@
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;

class CategoryControllerTest extends TestCase
Expand Down Expand Up @@ -451,6 +450,5 @@ public function an_admin_cannot_delete_an_existing_category_with_members()
$this->assertEquals(1, $category->entities()->count());
$this->assertEquals(1, Entity::count());
$this->assertEquals(route('categories.show', $category), url()->current());
Queue::assertPushed(EduGainAddEntity::class);
}
}
54 changes: 25 additions & 29 deletions tests/Feature/Http/Controllers/EntityControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Tests\Feature\Http\Controllers;

use App\Jobs\EduGainAddEntity;
use App\Jobs\EduGainDeleteEntity;
use App\Jobs\FolderDeleteEntity;
use App\Models\Entity;
use App\Models\Federation;
Expand Down Expand Up @@ -42,7 +40,7 @@ public function an_anonymouse_user_isnt_shown_an_entities_details()
->assertSeeText('login');

$this->assertEquals(route('login'), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down Expand Up @@ -87,7 +85,7 @@ public function an_anonymouse_user_cannot_see_entities_edit_page()

$this->assertEquals(1, Entity::count());
$this->assertEquals(route('login'), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -103,7 +101,7 @@ public function an_anonymouse_user_cannot_edit_an_existing_entity()

$this->assertEquals(1, Entity::count());
$this->assertEquals(route('login'), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -122,7 +120,6 @@ public function an_anonymouse_user_cannot_change_an_existing_entities_state()

$this->assertFalse($entity->trashed());
$this->assertEquals(route('login'), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

Expand Down Expand Up @@ -157,7 +154,7 @@ public function an_anonymouse_user_cannot_change_an_existing_entities_operators(

$this->assertEquals(1, $entity->operators()->count());
$this->assertEquals(route('login'), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -175,7 +172,7 @@ public function an_anonymouse_user_cannot_change_an_existing_entities_federation
->followingRedirects()
->post(route('entities.leave', $entity))
->assertSeeText('login');
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -192,7 +189,7 @@ public function an_anonymouse_user_cannot_purge_an_existing_entity()
->assertSeeText('login');

$this->assertEquals(route('login'), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down Expand Up @@ -249,7 +246,7 @@ public function a_user_is_shown_a_entities_list()

$this->assertEquals(1, Entity::count());
$this->assertEquals(route('entities.index'), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -271,7 +268,7 @@ public function a_user_is_shown_a_entities_details()

$this->assertEquals(1, Entity::count());
$this->assertEquals(route('entities.show', $entity), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down Expand Up @@ -504,7 +501,7 @@ public function a_user_with_operator_permission_can_see_entities_edit_page()
->assertSeeText(__('entities.profile'));

$this->assertEquals(route('entities.edit', $entity), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down Expand Up @@ -746,7 +743,7 @@ public function a_user_with_operator_permission_can_change_an_existing_entities_
$entity->refresh();
$this->assertEquals(1, $entity->operators()->count());
$this->assertEquals(route('entities.show', $entity), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -771,7 +768,7 @@ public function a_user_with_operator_permission_can_change_an_existing_entities_
->assertSeeText(__('entities.join_requested', ['name' => $federation->name]));

$this->assertEquals(1, Membership::whereApproved(false)->count());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -785,7 +782,7 @@ public function a_user_without_operator_permission_cannot_see_entities_edit_page
->actingAs($user)
->get(route('entities.edit', $entity))
->assertForbidden();
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -794,15 +791,14 @@ public function a_user_without_operator_permission_cannot_edit_an_existing_entit
Queue::fake();
$entity = Entity::factory()->create(['entityid' => 'https://whoami.cesnet.cz/idp/shibboleth']);


$this
->followingRedirects()
->patch(route('entities.update', $entity), [
'action' => 'update',
'url' => 'https://whoami.cesnet.cz/idp/shibboleth',
])
->assertSeeText('login');
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -818,7 +814,7 @@ public function a_user_without_operator_permission_cannot_change_an_existing_ent
->actingAs($user)
->patch(route('entities.update', $entity), ['action' => 'state'])
->assertForbidden();
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down Expand Up @@ -847,7 +843,7 @@ public function a_user_without_operator_permission_cannot_change_an_existing_ent
'operators' => [$new_operator->id],
])
->assertForbidden();
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -871,7 +867,7 @@ public function a_user_without_operator_permission_cannot_change_an_existing_ent
->assertForbidden();

$this->assertEquals(0, Membership::whereApproved(false)->count());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -888,7 +884,7 @@ public function a_user_cannot_purge_an_existing_entity()
->actingAs($user)
->delete(route('entities.destroy', $entity))
->assertForbidden();
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down Expand Up @@ -948,7 +944,7 @@ public function an_admin_is_shown_a_entities_list()

$this->assertEquals(1, Entity::count());
$this->assertEquals(route('entities.index'), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -968,7 +964,7 @@ public function an_admin_is_shown_a_entities_details()

$this->assertEquals(1, Entity::count());
$this->assertEquals(route('entities.show', $entity), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down Expand Up @@ -1172,7 +1168,7 @@ public function an_admin_can_see_entities_edit_page()

$this->assertEquals(1, Entity::count());
$this->assertEquals(route('entities.edit', $entity), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down Expand Up @@ -1432,7 +1428,7 @@ public function an_admin_can_change_an_existing_entities_operators()
$entity->refresh();
$this->assertEquals(0, $entity->operators()->count());
$this->assertEquals(route('entities.show', $entity), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -1457,7 +1453,7 @@ public function an_admin_can_change_an_existing_entities_federation_membership()
->assertSeeText(__('entities.join_requested', ['name' => $federation->name]));

$this->assertEquals(1, Membership::whereApproved(false)->count());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down Expand Up @@ -1537,7 +1533,7 @@ public function not_even_an_admin_can_run_update_function_without_definig_action
->put(route('entities.update', $entity));

$this->assertEquals(route('home'), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -1559,7 +1555,7 @@ public function ask_rs_isnt_shown_for_sp_entities_not_in_rs_federation()
->post(route('entities.rs', $entity))
->assertStatus(403)
->assertSeeText(__('entities.rs_only_for_eduidcz_members'));
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down Expand Up @@ -1588,6 +1584,6 @@ public function ask_rs_is_shown_for_sp_entities_in_rs_federation()
->post(route('entities.rs', $entity))
->assertStatus(200)
->assertSeeText(__('entities.rs_asked'));
Queue::assertPushed(EduGainAddEntity::class);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests\Feature\Http\Controllers;

use App\Jobs\EduGainAddEntity;
use App\Models\Entity;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
Expand All @@ -23,7 +22,7 @@ public function anonymouse_user_is_redirected_to_login(): void
->followingRedirects()
->get(route('entities.metadata', $entity))
->assertSeeText('login');
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down
7 changes: 3 additions & 4 deletions tests/Feature/Http/Controllers/FederationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests\Feature\Http\Controllers;

use App\Jobs\EduGainAddEntity;
use App\Jobs\GitDeleteMembers;
use App\Jobs\GitUpdateFederation;
use App\Jobs\Old_GitAddFederation;
Expand All @@ -13,9 +12,9 @@
use App\Notifications\FederationRejected;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;

class FederationControllerTest extends TestCase
Expand Down Expand Up @@ -197,7 +196,7 @@ public function an_anonymouse_user_cannot_change_an_existing_federations_entitie

$this->assertEquals(1, $federation->entities()->count());
$this->assertEquals(route('login'), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down Expand Up @@ -710,7 +709,7 @@ public function a_user_without_operator_permission_cannot_change_an_existing_fed
$federation->refresh();
$this->assertEquals(1, $federation->entities()->count());
$this->assertEquals(route('federations.show', $federation), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand Down
3 changes: 1 addition & 2 deletions tests/Feature/Http/Controllers/GroupControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests\Feature\Http\Controllers;

use App\Jobs\EduGainAddEntity;
use App\Jobs\GitAddGroup;
use App\Jobs\GitDeleteGroup;
use App\Jobs\GitUpdateGroup;
Expand Down Expand Up @@ -423,6 +422,6 @@ public function an_admin_cannot_delete_an_existing_group_with_members()
$this->assertEquals(1, $group->entities()->count());
$this->assertEquals(1, Entity::count());
$this->assertEquals(route('groups.show', $group), url()->current());
Queue::assertPushed(EduGainAddEntity::class);

}
}
3 changes: 1 addition & 2 deletions tests/Feature/Http/Controllers/StatisticControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests\Feature\Http\Controllers;

use App\Jobs\EduGainAddEntity;
use App\Models\Category;
use App\Models\Entity;
use App\Models\Federation;
Expand Down Expand Up @@ -84,6 +83,6 @@ public function it_produces_statistics(): void
],
],
]);
Queue::assertPushed(EduGainAddEntity::class);

}
}
5 changes: 2 additions & 3 deletions tests/Feature/Mail/AskRsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests\Feature\Mail;

use App\Jobs\EduGainAddEntity;
use App\Mail\AskRs;
use App\Models\Entity;
use App\Models\Federation;
Expand Down Expand Up @@ -43,7 +42,7 @@ public function email_is_queued_for_rs_federation_only()
return $email->hasTo(config('mail.admin.address')) &&
$email->entity->is($entity);
});
Queue::assertPushed(EduGainAddEntity::class);

}

/** @test */
Expand All @@ -61,6 +60,6 @@ public function email_isnt_queued_for_non_rs_federation()
->assertStatus(403);

Mail::assertNotQueued(AskRs::class);
Queue::assertPushed(EduGainAddEntity::class);

}
}

0 comments on commit 3aa5ac3

Please sign in to comment.