diff --git a/tests/Parse/ParseRoleTest.php b/tests/Parse/ParseRoleTest.php index f055a6ece2..4195bb6aaa 100644 --- a/tests/Parse/ParseRoleTest.php +++ b/tests/Parse/ParseRoleTest.php @@ -44,22 +44,22 @@ public function testRoleWithoutACLFails() public function testNameValidation() { - $role = ParseRole::createRole("Admin", $this->aclPublic()); - $this->assertEquals("Admin", $role->getName()); - $role->setName("Superuser"); - $this->assertEquals("Superuser", $role->getName()); - $role->setName("Super-Users"); - $this->assertEquals("Super-Users", $role->getName()); - $role->setName("A1234"); - $this->assertEquals("A1234", $role->getName()); + $role = ParseRole::createRole('Admin', $this->aclPublic()); + $this->assertEquals('Admin', $role->getName()); + $role->setName('Superuser'); + $this->assertEquals('Superuser', $role->getName()); + $role->setName('Super-Users'); + $this->assertEquals('Super-Users', $role->getName()); + $role->setName('A1234'); + $this->assertEquals('A1234', $role->getName()); $role->save(); $this->setExpectedException('Parse\ParseException', 'has been saved'); - $role->setName("Moderators"); + $role->setName('Moderators'); } public function testGetCreatedRole() { - $role = ParseRole::createRole("Admin", $this->aclPublic()); + $role = ParseRole::createRole('Admin', $this->aclPublic()); $role->save(); $query = ParseRole::query(); $obj = $query->get($role->getObjectId()); @@ -69,24 +69,24 @@ public function testGetCreatedRole() public function testFindRolesByName() { - $admin = ParseRole::createRole("Admin", $this->aclPublic()); - $mod = ParseRole::createRole("Moderator", $this->aclPublic()); + $admin = ParseRole::createRole('Admin', $this->aclPublic()); + $mod = ParseRole::createRole('Moderator', $this->aclPublic()); ParseObject::saveAll([$admin, $mod]); $query1 = ParseRole::query(); - $query1->equalTo("name", "Admin"); - $this->assertEquals(1, $query1->count(), "Count should be 1."); + $query1->equalTo('name', 'Admin'); + $this->assertEquals(1, $query1->count(), 'Count should be 1.'); $query2 = ParseRole::query(); - $query2->equalTo("name", "Moderator"); - $this->assertEquals(1, $query2->count(), "Count should be 1."); + $query2->equalTo('name', 'Moderator'); + $this->assertEquals(1, $query2->count(), 'Count should be 1.'); $query3 = ParseRole::query(); $this->assertEquals(2, $query3->count()); } public function testRoleNameUnique() { - $role = ParseRole::createRole("Admin", $this->aclPublic()); + $role = ParseRole::createRole('Admin', $this->aclPublic()); $role->save(); - $role2 = ParseRole::createRole("Admin", $this->aclPublic()); + $role2 = ParseRole::createRole('Admin', $this->aclPublic()); $this->setExpectedException('Parse\ParseException', 'duplicate'); $role2->save(); } @@ -94,12 +94,12 @@ public function testRoleNameUnique() public function testExplicitRoleACL() { $eden = $this->createEden(); - ParseUser::logIn("adam", "adam"); - $query = new ParseQuery("Things"); + ParseUser::logIn('adam', 'adam'); + $query = new ParseQuery('Things'); $apple = $query->get($eden['apple']->getObjectId()); - ParseUser::logIn("eve", "eve"); + ParseUser::logIn('eve', 'eve'); $apple = $query->get($eden['apple']->getObjectId()); - ParseUser::logIn("snake", "snake"); + ParseUser::logIn('snake', 'snake'); $this->setExpectedException('Parse\ParseException', 'not found'); $apple = $query->get($eden['apple']->getObjectId()); } @@ -107,45 +107,45 @@ public function testExplicitRoleACL() public function testRoleHierarchyAndPropagation() { $eden = $this->createEden(); - ParseUser::logIn("adam", "adam"); - $query = new ParseQuery("Things"); + ParseUser::logIn('adam', 'adam'); + $query = new ParseQuery('Things'); $garden = $query->get($eden['garden']->getObjectId()); - ParseUser::logIn("eve", "eve"); + ParseUser::logIn('eve', 'eve'); $garden = $query->get($eden['garden']->getObjectId()); - ParseUser::logIn("snake", "snake"); + ParseUser::logIn('snake', 'snake'); $garden = $query->get($eden['garden']->getObjectId()); $eden['edenkin']->getRoles()->remove($eden['humans']); $eden['edenkin']->save(); - ParseUser::logIn("adam", "adam"); + ParseUser::logIn('adam', 'adam'); try { $query->get($eden['garden']->getObjectId()); - $this->fail("Get should have failed."); + $this->fail('Get should have failed.'); } catch (\Parse\ParseException $ex) { - if ($ex->getMessage() != "Object not found.") { + if ($ex->getMessage() != 'Object not found.') { throw $ex; } } - ParseUser::logIn("eve", "eve"); + ParseUser::logIn('eve', 'eve'); try { $query->get($eden['garden']->getObjectId()); - $this->fail("Get should have failed."); + $this->fail('Get should have failed.'); } catch (\Parse\ParseException $ex) { - if ($ex->getMessage() != "Object not found.") { + if ($ex->getMessage() != 'Object not found.') { throw $ex; } } - ParseUser::logIn("snake", "snake"); + ParseUser::logIn('snake', 'snake'); $query->get($eden['garden']->getObjectId()); } public function testAddUserAfterFetch() { $user = new ParseUser(); - $user->setUsername("bob"); - $user->setPassword("barker"); + $user->setUsername('bob'); + $user->setPassword('barker'); $user->signUp(); - $role = ParseRole::createRole("MyRole", ParseACL::createACLWithUser($user)); + $role = ParseRole::createRole('MyRole', ParseACL::createACLWithUser($user)); $role->save(); $query = ParseRole::query(); $roleAgain = $query->get($role->getObjectId()); @@ -192,27 +192,27 @@ public function createEden() $eden['adam']->signUp(); $eden['eve']->signUp(); $eden['snake']->signUp(); - $eden['humans'] = ParseRole::createRole("humans", $this->aclPublic()); + $eden['humans'] = ParseRole::createRole('humans', $this->aclPublic()); $eden['humans']->getUsers()->add($eden['adam']); $eden['humans']->getUsers()->add($eden['eve']); $eden['creatures'] = ParseRole::createRole( - "creatures", + 'creatures', $this->aclPublic() ); $eden['creatures']->getUsers()->add($eden['snake']); ParseObject::saveAll([$eden['humans'], $eden['creatures']]); - $eden['edenkin'] = ParseRole::createRole("edenkin", $this->aclPublic()); + $eden['edenkin'] = ParseRole::createRole('edenkin', $this->aclPublic()); $eden['edenkin']->getRoles()->add($eden['humans']); $eden['edenkin']->getRoles()->add($eden['creatures']); $eden['edenkin']->save(); - $eden['apple'] = ParseObject::create("Things"); - $eden['apple']->set("name", "apple"); - $eden['apple']->set("ACL", $this->aclPrivateTo($eden['humans'])); + $eden['apple'] = ParseObject::create('Things'); + $eden['apple']->set('name', 'apple'); + $eden['apple']->set('ACL', $this->aclPrivateTo($eden['humans'])); - $eden['garden'] = ParseObject::create("Things"); - $eden['garden']->set("name", "garden"); - $eden['garden']->set("ACL", $this->aclPrivateTo($eden['edenkin'])); + $eden['garden'] = ParseObject::create('Things'); + $eden['garden']->set('name', 'garden'); + $eden['garden']->set('ACL', $this->aclPrivateTo($eden['edenkin'])); ParseObject::saveAll([$eden['apple'], $eden['garden']]);