setupPublicAndNonPublicComponentGroups() ->setupConfig(); } public function testIndexShowsOnlyPublicComponentGroupsToGues() { $this->visit('/') ->see(self::COMPONENT_GROUP_1_NAME) ->dontSee(self::COMPONENT_GROUP_2_NAME); } public function testIndexShowsAllComponentGroupsToLoggedInUsers() { $this->signIn(); $this->visit('/') ->see(self::COMPONENT_GROUP_1_NAME) ->see(self::COMPONENT_GROUP_2_NAME); } /** * Set up the needed data for the components groups tests. * * @return AbstractTestCase */ protected function setupPublicAndNonPublicComponentGroups() { $this->createAComponentGroupAndAddAComponent(self::COMPONENT_GROUP_1_NAME, ComponentGroup::VISIBLE_GUEST) ->createAComponentGroupAndAddAComponent(self::COMPONENT_GROUP_2_NAME, ComponentGroup::VISIBLE_AUTHENTICATED); factory(Setting::class)->create(); return $this; } /** * Create a component group and add one component to it. * * @param string $name * @param string $visible * * @return AbstractTestCase */ protected function createAComponentGroupAndAddAComponent($name, $visible) { factory(ComponentGroup::class) ->create(['name' => $name, 'visible' => $visible]) ->components() ->save(factory(Component::class)->create()); return $this; } }