From 92b7dd3335a6572debeacfb5faa82c63a5e67888 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 8 Jun 2018 20:03:25 +0200 Subject: Some minor fixes --- .../admin/tests/Integration/SprunjeTests.php | 218 ++++++++++----------- 1 file changed, 109 insertions(+), 109 deletions(-) (limited to 'main/app/sprinkles/admin/tests') diff --git a/main/app/sprinkles/admin/tests/Integration/SprunjeTests.php b/main/app/sprinkles/admin/tests/Integration/SprunjeTests.php index 47106e0..54a373d 100644 --- a/main/app/sprinkles/admin/tests/Integration/SprunjeTests.php +++ b/main/app/sprinkles/admin/tests/Integration/SprunjeTests.php @@ -1,109 +1,109 @@ -classMapper = new ClassMapper(); - } - - /** - * Tests... - */ - public function testUserPermissionSprunje() { - $fm = $this->ci->factory; - - // Generate some test models - $users = $fm->seed(3, 'UserFrosting\Sprinkle\Account\Database\Models\User'); - $roles = $fm->seed(3, 'UserFrosting\Sprinkle\Account\Database\Models\Role'); - $permissions = $fm->seed(3, 'UserFrosting\Sprinkle\Account\Database\Models\Permission'); - - // Create some relationships - $roles[0]->permissions()->attach($permissions[1]); - $roles[0]->permissions()->attach($permissions[2]); - $roles[1]->permissions()->attach($permissions[2]); - $roles[2]->permissions()->attach($permissions[0]); - $roles[2]->permissions()->attach($permissions[1]); - - $users[0]->roles()->attach($roles[1]); - $users[0]->roles()->attach($roles[2]); - $users[1]->roles()->attach($roles[0]); - $users[1]->roles()->attach($roles[1]); - $users[2]->roles()->attach($roles[1]); - - $this->classMapper->setClassMapping('user', 'UserFrosting\Sprinkle\Account\Database\Models\User'); - - // Test user 0 - $sprunje = new UserPermissionSprunje($this->classMapper, [ - 'user_id' => $users[0]->id - ]); - - list($count, $countFiltered, $models) = $sprunje->getModels(); - - // Check that counts are correct - $this->assertEquals(count($models), $count); - $this->assertEquals(count($models), $countFiltered); - - // Ignore pivot and roles_via. These are covered by the tests for the relationships themselves. - static::ignoreRelations($models); - $this->assertCollectionsSame(collect($permissions), $models); - - // Test user 1 - $sprunje = new UserPermissionSprunje($this->classMapper, [ - 'user_id' => $users[1]->id - ]); - - list($count, $countFiltered, $models) = $sprunje->getModels(); - - // Check that counts are correct - $this->assertEquals(count($models), $count); - $this->assertEquals(count($models), $countFiltered); - - // Ignore pivot and roles_via. These are covered by the tests for the relationships themselves. - static::ignoreRelations($models); - $this->assertCollectionsSame(collect([ - $permissions[1], - $permissions[2] - ]), $models); - - // Test user 2 - $sprunje = new UserPermissionSprunje($this->classMapper, [ - 'user_id' => $users[2]->id - ]); - - list($count, $countFiltered, $models) = $sprunje->getModels(); - - // Check that counts are correct - $this->assertEquals(count($models), $count); - $this->assertEquals(count($models), $countFiltered); - - // Ignore pivot and roles_via. These are covered by the tests for the relationships themselves. - static::ignoreRelations($models); - $this->assertCollectionsSame(collect([ - $permissions[2] - ]), $models); - } -} +classMapper = new ClassMapper(); + } + + /** + * Tests... + */ + public function testUserPermissionSprunje() { + $fm = $this->ci->factory; + + // Generate some test models + $users = $fm->seed(3, 'UserFrosting\Sprinkle\Account\Database\Models\User'); + $roles = $fm->seed(3, 'UserFrosting\Sprinkle\Account\Database\Models\Role'); + $permissions = $fm->seed(3, 'UserFrosting\Sprinkle\Account\Database\Models\Permission'); + + // Create some relationships + $roles[0]->permissions()->attach($permissions[1]); + $roles[0]->permissions()->attach($permissions[2]); + $roles[1]->permissions()->attach($permissions[2]); + $roles[2]->permissions()->attach($permissions[0]); + $roles[2]->permissions()->attach($permissions[1]); + + $users[0]->roles()->attach($roles[1]); + $users[0]->roles()->attach($roles[2]); + $users[1]->roles()->attach($roles[0]); + $users[1]->roles()->attach($roles[1]); + $users[2]->roles()->attach($roles[1]); + + $this->classMapper->setClassMapping('user', 'UserFrosting\Sprinkle\Account\Database\Models\User'); + + // Test user 0 + $sprunje = new UserPermissionSprunje($this->classMapper, [ + 'user_id' => $users[0]->id + ]); + + list($count, $countFiltered, $models) = $sprunje->getModels(); + + // Check that counts are correct + $this->assertEquals(count($models), $count); + $this->assertEquals(count($models), $countFiltered); + + // Ignore pivot and roles_via. These are covered by the tests for the relationships themselves. + static::ignoreRelations($models); + $this->assertCollectionsSame(collect($permissions), $models); + + // Test user 1 + $sprunje = new UserPermissionSprunje($this->classMapper, [ + 'user_id' => $users[1]->id + ]); + + list($count, $countFiltered, $models) = $sprunje->getModels(); + + // Check that counts are correct + $this->assertEquals(count($models), $count); + $this->assertEquals(count($models), $countFiltered); + + // Ignore pivot and roles_via. These are covered by the tests for the relationships themselves. + static::ignoreRelations($models); + $this->assertCollectionsSame(collect([ + $permissions[1], + $permissions[2] + ]), $models); + + // Test user 2 + $sprunje = new UserPermissionSprunje($this->classMapper, [ + 'user_id' => $users[2]->id + ]); + + list($count, $countFiltered, $models) = $sprunje->getModels(); + + // Check that counts are correct + $this->assertEquals(count($models), $count); + $this->assertEquals(count($models), $countFiltered); + + // Ignore pivot and roles_via. These are covered by the tests for the relationships themselves. + static::ignoreRelations($models); + $this->assertCollectionsSame(collect([ + $permissions[2] + ]), $models); + } +} -- cgit v1.2.3