Http::response('', 200), 'https://nami.dpsg.de/ica/rest/nami/auth/manual/sessionStartup' => Http::response($this->successJson, 200), 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200), ]); $this->setCredentials(); Nami::login(); $this->assertEquals([ ['id' => 100, 'name' => 'Group', 'parent_id' => null] ], Nami::groups()->toArray()); Http::assertSent(function($request) { return $request->url() == 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root'; }); Http::assertSentCount(3); } public function test_has_group_access() { Http::fake([ 'https://nami.dpsg.de/ica/pages/login.jsp' => Http::response('', 200), 'https://nami.dpsg.de/ica/rest/nami/auth/manual/sessionStartup' => Http::response($this->successJson, 200), 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200), ]); $this->setCredentials(); Nami::login(); $this->assertTrue(Nami::hasGroup(100)); $this->assertFalse(Nami::hasGroup(10101)); Http::assertSentCount(4); } public function test_get_subgroups_for_a_group() { Http::fake([ 'https://nami.dpsg.de/ica/pages/login.jsp' => Http::response('', 200), 'https://nami.dpsg.de/ica/rest/nami/auth/manual/sessionStartup' => Http::response($this->successJson, 200), 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200), 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/100' => Http::response($this->subgroupsResponse, 200) ]); $this->setCredentials(); Nami::login(); $subgroups = Nami::group(100)->subgroups(); $this->assertEquals([ ['id' => 101300, 'parent_id' => 100, 'name' => 'Siebengebirge'], ['id' => 100900, 'parent_id' => 100, 'name' => 'Sieg'], ['id' => 100900, 'parent_id' => 100, 'name' => 'Sieg'], ['id' => 101000, 'parent_id' => 100, 'name' => 'Voreifel'] ], $subgroups->toArray()); $subgroups->each(function($group) { $this->assertInstanceOf(Group::class, $group); }); Http::assertSent(function($request) { return $request->url() == 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root'; }); Http::assertSent(function($request) { return $request->url() == 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/100'; }); Http::assertSentCount(4); } }