コード例 #1
0
ファイル: SiteMoveTest.php プロジェクト: Tom-Byrne/gocdb
 public function testSiteMoves()
 {
     print __METHOD__ . "\n";
     //Insert initial data
     $N1 = TestUtil::createSampleNGI("NGI1");
     $N2 = TestUtil::createSampleNGI("NGI2");
     $S1 = TestUtil::createSampleSite("Site1");
     $S2 = TestUtil::createSampleSite("Site2");
     $S3 = TestUtil::createSampleSite("Site3");
     $SE1 = TestUtil::createSampleService("SEP1");
     $dummy_user = TestUtil::createSampleUser('Test', 'User', '/Some/string');
     //Make dummy user a GOCDB admin so it can perfirm site moves etc.
     $dummy_user->setAdmin(true);
     /*
      * Current code in TestUtil does not set sites up as being owned by an an NGI by default.
      *Add them to NGI
      */
     $N1->addSiteDoJoin($S1);
     $N2->addSiteDoJoin($S2);
     $N2->addSiteDoJoin($S3);
     //Add service end point to service 1
     $S1->addServiceDoJoin($SE1);
     //Persist initial data
     $this->em->persist($N1);
     $this->em->persist($N2);
     $this->em->persist($S1);
     $this->em->persist($S2);
     $this->em->persist($S3);
     $this->em->persist($SE1);
     $this->em->persist($dummy_user);
     $this->em->flush();
     //Use DB connection to check data
     $con = $this->getConnection();
     /*
      * Check both that each NGI is present and that the ID matches the doctrine one
      */
     $N1_ID = $N1->getId();
     $sql = "SELECT 1 FROM ngis WHERE name = 'NGI1' AND ID = '{$N1_ID}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(1, $result->getRowCount());
     $N2_ID = $N2->getId();
     $sql = "SELECT 1 FROM ngis WHERE name = 'NGI2' AND ID = '{$N2_ID}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(1, $result->getRowCount());
     /*
      * Check each site is: present, has the right ID & parent NGI
      */
     $S1_id = $S1->getId();
     $sql = "SELECT 1 FROM sites WHERE shortname = 'Site1' AND ID = '{$S1_id}' AND NGI_ID = '{$N1_ID}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(1, $result->getRowCount());
     $S2_id = $S2->getId();
     $sql = "SELECT 1 FROM sites WHERE shortname = 'Site2' AND ID = '{$S2_id}' AND NGI_ID = '{$N2_ID}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(1, $result->getRowCount());
     $S3_id = $S3->getId();
     $sql = "SELECT 1 FROM sites WHERE shortname = 'Site3' AND ID = '{$S3_id}' AND NGI_ID = '{$N2_ID}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(1, $result->getRowCount());
     //Check the SEP has correct id and Site
     $sql = "SELECT 1 FROM services WHERE hostname = 'SEP1' AND parentsite_id = '{$S1_id}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(1, $result->getRowCount());
     //Move sites
     $serv = new org\gocdb\services\Site();
     $serv->setEntityManager($this->em);
     $serv->moveSite($S1, $N2, $dummy_user);
     $serv->moveSite($S2, $N1, $dummy_user);
     $serv->moveSite($S3, $N2, $dummy_user);
     //No change
     //flush movement
     $this->em->flush();
     //Use doctrine to check movement
     //Check correct NGI for each site
     $this->assertEquals($N2, $S1->getNgi());
     $this->assertEquals($N1, $S2->getNgi());
     $this->assertEquals($N2, $S3->getNgi());
     //Check correct sites for each NGI
     //NGI1
     $ngisites = $N1->getSites();
     foreach ($ngisites as $site) {
         $this->assertEquals($S2, $site);
     }
     //NGI2
     $ngisites = $N2->getSites();
     foreach ($ngisites as $site) {
         $this->assertTrue($site == $S1 or $site == $S3);
     }
     //check Service End Point
     $this->assertEquals($S1, $SE1->getParentSite());
     //Use database connection to check movememrnt
     $con = $this->getConnection();
     //Check NGIs are still present and their ID is unchanged
     $sql = "SELECT 1 FROM ngis WHERE name = 'NGI1' AND ID = '{$N1_ID}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(1, $result->getRowCount());
     $sql = "SELECT 1 FROM ngis WHERE name = 'NGI2' AND ID = '{$N2_ID}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(1, $result->getRowCount());
     //Check each NGI has the correct number of sites
     //NGI1
     $sql = "SELECT 1 FROM sites WHERE NGI_ID = '{$N1_ID}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(1, $result->getRowCount());
     //NGI2
     $sql = "SELECT 1 FROM sites WHERE NGI_ID = '{$N2_ID}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(2, $result->getRowCount());
     //check Site IDs are unchanged and they are assigned to the correct NGI
     //Site 1
     $sql = "SELECT 1 FROM sites WHERE shortname = 'Site1' AND ID = '{$S1_id}' AND NGI_ID = '{$N2_ID}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(1, $result->getRowCount());
     //Site 2
     $sql = "SELECT 1 FROM sites WHERE shortname = 'Site2' AND ID = '{$S2_id}' AND NGI_ID = '{$N1_ID}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(1, $result->getRowCount());
     //Site 3
     $sql = "SELECT 1 FROM sites WHERE shortname = 'Site3' AND ID = '{$S3_id}' AND NGI_ID = '{$N2_ID}'";
     $result = $con->createQueryTable('', $sql);
     $this->assertEquals(1, $result->getRowCount());
 }
コード例 #2
0
<?php

/*
 * Include this file in your tests in order to persist a set of known fixuture data 
 * for subsequent use in testing.
 *  
 * @author David Meredith 
 */
/*
 */
// Sites ****************************
$site0 = TestUtil::createSampleSite("Site0");
$site1 = TestUtil::createSampleSite("Site1");
$site2 = TestUtil::createSampleSite("Site2");
$site3 = TestUtil::createSampleSite("Site3");
$site4 = TestUtil::createSampleSite("Site4");
$this->em->persist($site0);
$this->em->persist($site1);
$this->em->persist($site2);
$this->em->persist($site3);
$this->em->persist($site4);
// Sites ****************************
// site1 has 1 prop
$s1p1 = TestUtil::createSampleSiteProperty("s1p1", "v1");
$site1->addSitePropertyDoJoin($s1p1);
$this->em->persist($s1p1);
// site2 has 2 props
$s2p1 = TestUtil::createSampleSiteProperty("s2p1", "v1");
$s2p2 = TestUtil::createSampleSiteProperty("s2p2", "v2");
$this->em->persist($s2p1);
$this->em->persist($s2p2);
コード例 #3
0
 /**
  * Assert that deletion of an OwnedEntity superclass will delete its joined 
  * extending class (e.g. Site and NGI). 
  */
 public function testCascadeDeleteFromOwnedEntity()
 {
     print __METHOD__ . "\n";
     // create and commit a new site
     $s = TestUtil::createSampleSite("SITENAME");
     $this->em->persist($s);
     $this->em->flush();
     // lookup the site's super class (OwnedEntity)
     $siteID = $s->getId();
     $ownedEntity = $this->em->find("OwnedEntity", $siteID);
     $this->assertNotNull($ownedEntity);
     $this->assertTrue($ownedEntity instanceof OwnedEntity);
     $this->assertEquals($siteID, $ownedEntity->getId());
     // remove the super class - this should cascade delete the site
     $this->em->remove($ownedEntity);
     $this->em->flush();
     // Assert that the super class was deleted and site was cascade deleted
     // first using doctrine
     $siteAgain = $this->em->find("Site", $siteID);
     $this->assertNull($siteAgain);
     $ownedEntityAgain = $this->em->find("OwnedEntity", $siteID);
     $this->assertNull($ownedEntityAgain);
     // second using separate db connection
     $testConn = $this->getConnection();
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM OwnedEntities");
     $this->assertTrue($result->getRowCount() == 0);
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM Sites");
     $this->assertTrue($result->getRowCount() == 0);
 }
コード例 #4
0
 * See the corresponding fixtureDataERD.svg file for an ERD of this fixture data 
 * 
 * @author David Meredith 
 */
$roleType1 = TestUtil::createSampleRoleType("NAME");
$roleType2 = TestUtil::createSampleRoleType("NAME2");
$this->em->persist($roleType1);
$this->em->persist($roleType2);
// Create a user
$userWithRoles = TestUtil::createSampleUser("Test", "Testing", "/c=test");
$this->em->persist($userWithRoles);
$userId = $userWithRoles->getId();
// Create an NGI, site and services
$ngi = TestUtil::createSampleNGI("MYNGI");
$site1 = TestUtil::createSampleSite('site1');
$site2 = TestUtil::createSampleSite('site2');
$service1 = TestUtil::createSampleService('site1_service1');
$service2 = TestUtil::createSampleService('site1_service2');
$endpoint1 = TestUtil::createSampleEndpointLocation();
$downtime1 = TestUtil::createSampleDowntime();
$downtime2 = TestUtil::createSampleDowntime();
$service1->addEndpointLocationDoJoin($endpoint1);
$downtime1->addEndpointLocation($endpoint1);
$downtime2->addEndpointLocation($endpoint1);
$site1->addServiceDoJoin($service1);
$site1->addServiceDoJoin($service2);
$ngi->addSiteDoJoin($site1);
$ngi->addSiteDoJoin($site2);
$certStatusLog1 = TestUtil::createSampleCertStatusLog();
$certStatusLog2 = TestUtil::createSampleCertStatusLog();
$site2->addCertificationStatusLog($certStatusLog1);
コード例 #5
0
ファイル: RoleServiceTest.php プロジェクト: Tom-Byrne/gocdb
 public function testGetUserRoles()
 {
     print __METHOD__ . "\n";
     // Create two roletypes
     $ngiRoleType = TestUtil::createSampleRoleType("RT1_NAME");
     $siteRoleType = TestUtil::createSampleRoleType("RT2_NAME");
     $this->em->persist($ngiRoleType);
     $this->em->persist($siteRoleType);
     // Create a user
     $u = TestUtil::createSampleUser("Test", "Testing", "/c=test");
     $this->em->persist($u);
     // Create an NGI
     $ngi = TestUtil::createSampleNGI("MYNGI");
     $this->em->persist($ngi);
     // Create a Role and link to the User, ngiRoleType and ngi
     $roleNgi = TestUtil::createSampleRole($u, $ngiRoleType, $ngi, RoleStatus::GRANTED);
     $this->em->persist($roleNgi);
     // Create a site
     $site1 = TestUtil::createSampleSite("SITENAME");
     $this->em->persist($site1);
     // Create another role and link to the User, siteRoleType and site
     $roleSite = TestUtil::createSampleRole($u, $siteRoleType, $site1, RoleStatus::GRANTED);
     $this->em->persist($roleSite);
     // Create a second and third sites and add to the NGI, but DO NOT add direct
     // roles over those sites for the user. The user will still have role
     // over the sites because they have a role over the NGI !
     $site2 = TestUtil::createSampleSite("SITENAME2");
     $site3 = TestUtil::createSampleSite("SITENAME3");
     $this->em->persist($site2);
     $this->em->persist($site3);
     $ngi->addSiteDoJoin($site2);
     $ngi->addSiteDoJoin($site3);
     $this->em->flush();
     // ********MUST******** start a new connection to test transactional
     // isolation of RoleService methods.
     $em = $this->createEntityManager();
     $roleService = new org\gocdb\services\Role();
     $roleService->setEntityManager($em);
     // assert that user has expected roles
     $roles = $roleService->getUserRoles($u, RoleStatus::GRANTED);
     $this->assertEquals(2, sizeof($roles));
     $this->assertTrue(count($roleService->getUserRoleNamesOverEntity($ngi, $u)) == 1);
     $this->assertTrue(count($roleService->getUserRoleNamesOverEntity($site1, $u)) == 1);
     $this->assertTrue(count($roleService->getUserRoleNamesOverEntity($site2, $u)) == 0);
     $this->assertTrue(count($roleService->getUserRoleNamesOverEntity($site3, $u)) == 0);
     // assert that the user has an expected site count with roles over those sites
     $mySites = $roleService->getReachableSitesFromOwnedObjectRoles($u);
     $this->assertEquals(3, sizeof($mySites));
     // assert user don't have these pending/revoked roles
     $roles = $roleService->getUserRoles($u, RoleStatus::PENDING);
     $this->assertEmpty($roles);
 }
コード例 #6
0
 /**
  * Persist some seed data - roletypes, user, Project, NGI, sites and SEs and 
  * assert that the user has the expected number of roles that grant specific 
  * actions over the owned objects. For example, assert that the user has 'n' 
  * number of roles that allow a particular site to be edited, or 'n' number 
  * of roles that allow an NGI certification status change.  
  */
 public function testAuthorizeAction1()
 {
     print __METHOD__ . "\n";
     // Create roletypes
     $siteAdminRT = TestUtil::createSampleRoleType(RoleTypeName::SITE_ADMIN);
     $ngiManRT = TestUtil::createSampleRoleType(RoleTypeName::NGI_OPS_MAN);
     $rodRT = TestUtil::createSampleRoleType(RoleTypeName::REG_STAFF_ROD);
     $codRT = TestUtil::createSampleRoleType(RoleTypeName::COD_ADMIN);
     $this->em->persist($siteAdminRT);
     // edit site1 (but not cert status)
     $this->em->persist($ngiManRT);
     // edit owned site1/site2 and cert status
     $this->em->persist($rodRT);
     // edit owned sites 1and2 (but not cert status)
     $this->em->persist($codRT);
     // edit all sites cert status only
     // Create a user
     $u = TestUtil::createSampleUser("Test", "Testing", "/c=test");
     $this->em->persist($u);
     // Create a linked object graph
     // NGI->Site1->SE
     //   |->Site2
     $ngi = TestUtil::createSampleNGI("MYNGI");
     $this->em->persist($ngi);
     $site1 = TestUtil::createSampleSite("SITENAME");
     //$site1->setNgiDoJoin($ngi);
     $ngi->addSiteDoJoin($site1);
     $this->em->persist($site1);
     $se1 = TestUtil::createSampleService('somelabel');
     $site1->addServiceDoJoin($se1);
     $this->em->persist($se1);
     $site2_userHasNoDirectRole = TestUtil::createSampleSite("SITENAME_2");
     $ngi->addSiteDoJoin($site2_userHasNoDirectRole);
     //$site2_userHasNoDirectRole->setNgiDoJoin($ngi);
     $this->em->persist($site2_userHasNoDirectRole);
     // Create ngiManagerRole, ngiUserRole, siteAdminRole and link user and owned entities
     $ngiManagerRole = TestUtil::createSampleRole($u, $ngiManRT, $ngi, RoleStatus::GRANTED);
     $this->em->persist($ngiManagerRole);
     $rodUserRole = TestUtil::createSampleRole($u, $rodRT, $ngi, RoleStatus::GRANTED);
     $this->em->persist($rodUserRole);
     $siteAdminRole = TestUtil::createSampleRole($u, $siteAdminRT, $site1, RoleStatus::GRANTED);
     $this->em->persist($siteAdminRole);
     $this->em->flush();
     // ********MUST******** start a new connection to test transactional
     // isolation of RoleService methods.
     $em = $this->createEntityManager();
     $siteService = new org\gocdb\services\Site();
     $siteService->setEntityManager($em);
     // Assert user can edit site using 3 enabling roles
     $enablingRoles = $siteService->authorizeAction(\Action::EDIT_OBJECT, $site1, $u);
     $this->assertEquals(3, count($enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::SITE_ADMIN, $enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::NGI_OPS_MAN, $enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::REG_STAFF_ROD, $enablingRoles));
     // Assert user can only edit cert status through his NGI_OPS_MAN role
     $enablingRoles = $siteService->authorizeAction(\Action::SITE_EDIT_CERT_STATUS, $site1, $u);
     $this->assertEquals(1, count($enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::NGI_OPS_MAN, $enablingRoles));
     // Add a new project and link ngi and give user COD_ADMIN Project role (use $this->em to isolate)
     // Project->NGI->Site1->SE
     //            |->Site2
     $proj = new Project('EGI project');
     $proj->addNgi($ngi);
     //$ngi->addProject($proj); // not strictly needed
     $this->em->persist($proj);
     $codRole = TestUtil::createSampleRole($u, $codRT, $proj, RoleStatus::GRANTED);
     $this->em->persist($codRole);
     $this->em->flush();
     // Assert user now has 2 roles that enable SITE_EDIT_CERT_STATUS change action
     $enablingRoles = $siteService->authorizeAction(\Action::SITE_EDIT_CERT_STATUS, $site1, $u);
     $this->assertEquals(2, count($enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::NGI_OPS_MAN, $enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::COD_ADMIN, $enablingRoles));
     // Assert user can edit SE using SITE_ADMIN, NGI_OPS_MAN, REG_STAFF_ROD roles (but not COD role)
     $seService = new org\gocdb\services\ServiceService();
     $seService->setEntityManager($em);
     $enablingRoles = $seService->authorizeAction(\Action::EDIT_OBJECT, $se1, $u);
     $this->assertEquals(3, count($enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::SITE_ADMIN, $enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::NGI_OPS_MAN, $enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::REG_STAFF_ROD, $enablingRoles));
     // Assert User can only edit Site2 through his 2 indirect ngi roles
     // (user don't have any direct site level roles on this site and COD don't give edit perm)
     $enablingRoles = $siteService->authorizeAction(\Action::EDIT_OBJECT, $site2_userHasNoDirectRole, $u);
     $this->assertEquals(2, count($enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::NGI_OPS_MAN, $enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::REG_STAFF_ROD, $enablingRoles));
     // Delete the user's Project COD role
     $this->em->remove($codRole);
     $this->em->flush();
     // Assert user can only SITE_EDIT_CERT_STATUS through 1 role for both sites
     $enablingRoles = $siteService->authorizeAction(\Action::SITE_EDIT_CERT_STATUS, $site2_userHasNoDirectRole, $u);
     $this->assertEquals(1, count($enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::NGI_OPS_MAN, $enablingRoles));
     $enablingRoles = $siteService->authorizeAction(\Action::SITE_EDIT_CERT_STATUS, $site1, $u);
     $this->assertEquals(1, count($enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::NGI_OPS_MAN, $enablingRoles));
     // Delete the user's NGI manager role
     $this->em->remove($ngiManagerRole);
     $this->em->flush();
     // Assert user can't edit site2 cert status
     $enablingRoles = $siteService->authorizeAction(\Action::SITE_EDIT_CERT_STATUS, $site2_userHasNoDirectRole, $u);
     $this->assertEquals(0, count($enablingRoles));
     // Assert user can still edit site via his ROD role
     $enablingRoles = $siteService->authorizeAction(\Action::EDIT_OBJECT, $site2_userHasNoDirectRole, $u);
     $this->assertEquals(1, count($enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::REG_STAFF_ROD, $enablingRoles));
     // Delete the user's NGI ROD role
     $this->em->remove($rodUserRole);
     $this->em->flush();
     // User can't edit site2
     $enablingRoles = $siteService->authorizeAction(\Action::EDIT_OBJECT, $site2_userHasNoDirectRole, $u);
     $this->assertEquals(0, count($enablingRoles));
     // Assert user can still edit SITE1 through his direct site level role (this role has not been deleted)
     $enablingRoles = $siteService->authorizeAction(\Action::EDIT_OBJECT, $site1, $u);
     $this->assertEquals(1, count($enablingRoles));
     $this->assertTrue(in_array(\RoleTypeName::SITE_ADMIN, $enablingRoles));
     // Delete user's remaining Site role
     $this->em->remove($siteAdminRole);
     $this->em->flush();
     // User can't edit site1
     $enablingRoles = $siteService->authorizeAction(\Action::EDIT_OBJECT, $site1, $u);
     $this->assertEquals(0, count($enablingRoles));
 }
コード例 #7
0
ファイル: ExtensionsTest.php プロジェクト: Tom-Byrne/gocdb
 /**
  * Show the creation of an endpoint and properties and that 
  * all data is removed on deletion of an endpoint or property
  */
 public function testEndpointPropertyDeletions()
 {
     print __METHOD__ . "\n";
     $service = TestUtil::createSampleService("TestService");
     $ngi = TestUtil::createSampleNGI("TestNGI");
     $site = TestUtil::createSampleSite("TestSite");
     $endpoint = TestUtil::createSampleEndpointLocation();
     //Join service to site, and site to NGI.
     $ngi->addSiteDoJoin($site);
     $site->addServiceDoJoin($service);
     $service->addEndpointLocationDoJoin($endpoint);
     //Create properties
     $prop1 = TestUtil::createSampleEndpointProperty("VO", "Atlas");
     $prop2 = TestUtil::createSampleEndpointProperty("VO", "CMS");
     $prop3 = TestUtil::createSampleEndpointProperty("VO", "Alice");
     $endpoint->addEndpointPropertyDoJoin($prop1);
     $endpoint->addEndpointPropertyDoJoin($prop2);
     $endpoint->addEndpointPropertyDoJoin($prop3);
     //Persist in the entity manager
     $this->em->persist($service);
     $this->em->persist($ngi);
     $this->em->persist($site);
     $this->em->persist($endpoint);
     $this->em->persist($prop1);
     $this->em->persist($prop2);
     $this->em->persist($prop3);
     //Commit to the database
     $this->em->flush();
     //Check endpoint has 3 properties associated with it
     $properties = $endpoint->getEndpointProperties();
     $this->assertTrue(count($properties) == 3);
     //Create an admin user that can delete a property
     $adminUser = TestUtil::createSampleUser('my', 'admin', '/my/admin');
     $adminUser->setAdmin(TRUE);
     $this->em->persist($adminUser);
     //Delete the property from the service
     $serviceService = new org\gocdb\services\ServiceService();
     $serviceService->setEntityManager($this->em);
     $serviceService->deleteEndpointProperty($adminUser, $prop1);
     //Check that the service now only has 2 properties
     $properties = $endpoint->getEndpointProperties();
     $this->assertTrue(count($properties) == 2);
     $this->em->flush();
     //Print names of properties
     foreach ($properties as $prop) {
         print $prop->getKeyName() . "-";
         print $prop->getKeyValue() . "\n";
     }
     //Check this via the database
     $con = $this->getConnection();
     //Get service id to use in sql statements
     $endpointId = $endpoint->getId();
     $result = $con->createQueryTable('results', "SELECT * FROM endpoint_properties WHERE PARENTENDPOINT_ID = '{$endpointId}'");
     //Assert that only 2 service properties exist in the database for this service
     $this->assertEquals(2, $result->getRowCount());
     //Now delete the endpont and check that it cascade deletes
     //the endpoint's associated properties
     $serviceService->deleteEndpoint($endpoint, $adminUser);
     $this->em->flush();
     //Check endpoint is gone
     $result = $con->createQueryTable('results', "SELECT * FROM EndpointLocations WHERE ID = '{$endpointId}'");
     $this->assertEquals(0, $result->getRowCount());
     //Check properties are gone
     $result = $con->createQueryTable('results', "SELECT * FROM endpoint_properties WHERE PARENTENDPOINT_ID = '{$endpointId}'");
     $this->assertEquals(0, $result->getRowCount());
 }
コード例 #8
0
ファイル: RolesTest.php プロジェクト: Tom-Byrne/gocdb
 /**
  * Test Role's discriminator column
  * Add a role type, user, site and a role linking
  * them all together. Assert that $newRole->getOwnedEntity()
  * returns an instanceof Site.
  */
 public function testRoleDiscriminatorSite()
 {
     print __METHOD__ . "\n";
     // Create a roletype
     $rt = TestUtil::createSampleRoleType("ROLENAME");
     $this->em->persist($rt);
     // Create a user
     $u = TestUtil::createSampleUser("Test", "Testing", "/c=test");
     $this->em->persist($u);
     // Create a site
     $s = TestUtil::createSampleSite("SITENAME");
     $this->em->persist($s);
     // Create a role and link to the user, role type and site
     $r = TestUtil::createSampleRole($u, $rt, $s, RoleStatus::GRANTED);
     $this->em->persist($r);
     $this->em->flush();
     // New reference to the freshly created role entity
     $dbRole = $this->em->find("Role", $r->getId());
     if (!$dbRole->getOwnedEntity() instanceof Site) {
         $this->fail();
     }
     // if we've reached this point without error the test
     // has passed.
 }