filters['advanced'] = $filters; } /** * Review the user preferences when the user does not save filters * @covers Configurations::getUserPreferences * @test */ public function it_should_return_default_filters() { $user = factory(User::class)->create(); $configuration = new Configurations(); //Get the user preferences $response = $configuration->getUserPreferences('FILTERS', $user->USR_UID); //Compare filters $this->assertEquals($response, ['advanced' => []]); } /** * Review the user preferences when the user save filters * @covers Configurations::getUserPreferences * @test */ public function it_should_return_filters_saved() { //Define a user $user = factory(User::class)->create(); //Save the configuration defined $configuration = new Configurations(); $configuration->aConfig['FILTERS'] = $this->filters; $configuration->saveConfig('USER_PREFERENCES', '', '', $user->USR_UID); //Get the user preferences $response = $configuration->getUserPreferences('FILTERS', $user->USR_UID); //Compare filters $this->assertEquals($response, $this->filters); //Review if some keys exist $this->assertArrayHasKey('category', $response['advanced']); $this->assertArrayHasKey('columnSearch', $response['advanced']); $this->assertArrayHasKey('dateFrom', $response['advanced']); $this->assertArrayHasKey('dateTo', $response['advanced']); $this->assertArrayHasKey('dir', $response['advanced']); $this->assertArrayHasKey('limit', $response['advanced']); $this->assertArrayHasKey('filterStatus', $response['advanced']); $this->assertArrayHasKey('process', $response['advanced']); $this->assertArrayHasKey('process_label', $response['advanced']); $this->assertArrayHasKey('search', $response['advanced']); $this->assertArrayHasKey('sort', $response['advanced']); $this->assertArrayHasKey('start', $response['advanced']); $this->assertArrayHasKey('user', $response['advanced']); $this->assertArrayHasKey('user_label', $response['advanced']); } }