test/snac/server/database/DBUserTest.php
/**
     * Test reading and writing an institution
     */
Test reading and writing an institution
Test reading and writing an institution
public function testInstitution()
    {
        $firstObj = new \snac\data\Constellation();
        $initialList = $this->dbu->listInstitutions();
        $firstObj->setID(1234);
        $this->dbu->writeInstitution($firstObj);
        $firstICID = $firstObj->getID();
        $secondObj = new \snac\data\Constellation();
        $secondObj->setID(4567);
        $this->dbu->writeInstitution($secondObj);
        $iList = $this->dbu->listInstitutions();
        $this->dbu->eraseInstitution($firstObj);
        $this->dbu->eraseInstitution($secondObj);
        $postList = $this->dbu->listInstitutions();
        $this->assertNotNull($firstObj->getID());
        $this->assertEquals($firstICID, 1234);
        $this->assertEquals($secondObj->getID(), 4567);
        $this->assertEquals(count($initialList), count($iList)-2);
        $this->assertEquals(count($initialList), count($postList));
    }
public function testInstitution ( ) { $ firstObj = new \ snac \ data \ Constellation ( ) ; $ initialList = $ this -> dbu -> listInstitutions ( ) ; $ firstObj -> setID ( 1234 ) ; $ this -> dbu -> writeInstitution ( $ firstObj ) ; $ firstICID = $ firstObj -> getID ( ) ; $ secondObj = new \ snac \ data \ Constellation ( ) ; $ secondObj -> setID ( 4567 ) ; $ this -> dbu -> writeInstitution ( $ secondObj ) ; $ iList = $ this -> dbu -> listInstitutions ( ) ; $ this -> dbu -> eraseInstitution ( $ firstObj ) ; $ this -> dbu -> eraseInstitution ( $ secondObj ) ; $ postList = $ this -> dbu -> listInstitutions ( ) ; $ this -> assertNotNull ( $ firstObj -> getID ( ) ) ; $ this -> assertEquals ( $ firstICID , 1234 ) ; $ this -> assertEquals ( $ secondObj -> getID ( ) , 4567 ) ; $ this -> assertEquals ( count ( $ initialList ) , count ( $ iList ) - 2 ) ; $ this -> assertEquals ( count ( $ initialList ) , count ( $ postList ) ) ; }
Test reading and writing an institution
Test reading and writing an institution
/*
         * Yes, it is a ficticious ic_id, but in the testing world, the ic_id isn't related to anything.
         * The first write tests insert, and the second tests update.
         *
         * Since we are using ic_id in table snac_institution, is it theoretically possible that 1234 and 4567
         * are valid ic_id values. Not likely, but possible. We could use 1 and 2 which are so small that they
         * will never be constellation IDs in the real world.
         *
         * The field typt is int, so we can use negative numbers for testing.
         */ /*
         * Do all the assertions at the end. Failed assertions halt execution, so any error prevents the test
         * from cleaning up. Of course, some kinds of frank bugs will prevent cleaning up as well.
         */