Exemplo n.º 1
0
 /**
  * @depends testRemovePolicies
  */
 public function testDeleteAllPolicies()
 {
     $nerd = User::getByUsername('billy');
     $salesStaff = Group::getByName('Sales Staff');
     $this->assertEquals(null, $nerd->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(null, $salesStaff->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(null, $nerd->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(null, $salesStaff->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $nerd->setPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS, 30);
     $this->assertTrue($nerd->save());
     $this->assertEquals(30, $nerd->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(null, $salesStaff->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $salesStaff->setPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS, 10);
     $this->assertTrue($salesStaff->save());
     $this->assertEquals(30, $nerd->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(10, $salesStaff->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     Policy::removeAllForPermitable($nerd);
     PoliciesCache::forgetAll();
     unset($nerd);
     unset($salesStaff);
     RedBeanModel::forgetAll();
     $nerd = User::getByUsername('billy');
     $salesStaff = Group::getByName('Sales Staff');
     $this->assertEquals(null, $nerd->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(10, $salesStaff->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     Policy::deleteAll();
     PoliciesCache::forgetAll();
     unset($nerd);
     unset($salesStaff);
     RedBeanModel::forgetAll();
     $nerd = User::getByUsername('billy');
     $salesStaff = Group::getByName('Sales Staff');
     $this->assertEquals(null, $nerd->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(null, $salesStaff->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
 }