test/snac/server/ServerTest.php
/**
     * Test inserting a constellation by the server
     */
Test inserting a constellation by the server
Test inserting a constellation by the server
public function testInsertConstellation() {
        $parser = new \snac\util\EACCPFParser();
        $parser->setConstellationOperation(\snac\data\AbstractData::$OPERATION_INSERT);
        $c = $parser->parseFile("test/snac/server/database/test_record.xml");
        $server = new Server( array(
                "command" => "insert_constellation",
                "user" => $this->user->toArray(),
                "constellation" => $c->toArray()
        ));
        $server->run();
        $response = $server->getResponse();
        $this->assertNotNull($response);
        $response = json_decode($response, true);
        $this->assertEquals("success", $response["result"]);
        $this->assertArrayHasKey("constellation", $response);
        $written = new \snac\data\Constellation($response["constellation"]);
        $server = new Server( array(
                "command" => "unlock_constellation",
                "user" => $this->user->toArray(),
                "constellation" => $written->toArray()
        ));
        $server->run();
        $response = $server->getResponse();
        $this->assertNotNull($response);
        $response = json_decode($response, true);
        $this->assertEquals("success", $response["result"]);
        $this->assertArrayHasKey("constellation", $response);
        $unlocked = new \snac\data\Constellation($response["constellation"]);
        $c2 = new \snac\data\Constellation($c->toArray());
        $this->assertTrue($c->equals($c), "Same constellation is not equal");
        $this->assertTrue($c2->equals($c), "Copy constellation is not equal");
        $this->assertTrue($written->equals($c, false), "Written copy is not equal to original");
        $this->assertTrue($written->equals($unlocked, false), "Written copy is not equal to unlocked version");
        return $unlocked;
    }
public function testInsertConstellation ( ) { $ parser = new \ snac \ util \ EACCPFParser ( ) ; $ parser -> setConstellationOperation ( \ snac \ data \ AbstractData :: $ OPERATION_INSERT ) ; $ c = $ parser -> parseFile ( " test/snac/server/database/test_record.xml " ) ; $ server = new Server ( array ( " command " => " insert_constellation " , " user " => $ this -> user -> toArray ( ) , " constellation " => $ c -> toArray ( ) ) ) ; $ server -> run ( ) ; $ response = $ server -> getResponse ( ) ; $ this -> assertNotNull ( $ response ) ; $ response = json_decode ( $ response , true ) ; $ this -> assertEquals ( " success " , $ response [ " result " ] ) ; $ this -> assertArrayHasKey ( " constellation " , $ response ) ; $ written = new \ snac \ data \ Constellation ( $ response [ " constellation " ] ) ; $ server = new Server ( array ( " command " => " unlock_constellation " , " user " => $ this -> user -> toArray ( ) , " constellation " => $ written -> toArray ( ) ) ) ; $ server -> run ( ) ; $ response = $ server -> getResponse ( ) ; $ this -> assertNotNull ( $ response ) ; $ response = json_decode ( $ response , true ) ; $ this -> assertEquals ( " success " , $ response [ " result " ] ) ; $ this -> assertArrayHasKey ( " constellation " , $ response ) ; $ unlocked = new \ snac \ data \ Constellation ( $ response [ " constellation " ] ) ; $ c2 = new \ snac \ data \ Constellation ( $ c -> toArray ( ) ) ; $ this -> assertTrue ( $ c -> equals ( $ c ) , " Same constellation is not equal " ) ; $ this -> assertTrue ( $ c2 -> equals ( $ c ) , " Copy constellation is not equal " ) ; $ this -> assertTrue ( $ written -> equals ( $ c , false ) , " Written copy is not equal to original " ) ; $ this -> assertTrue ( $ written -> equals ( $ unlocked , false ) , " Written copy is not equal to unlocked version " ) ; return $ unlocked ; }
Test inserting a constellation by the server
Test inserting a constellation by the server