PhpOrient\RecordCommandsTest::testCreateUpdateLoad PHP Method

testCreateUpdateLoad() public method

    public function testCreateUpdateLoad()
    {
        if ($this->client->getTransport()->getProtocolVersion() < 26) {
            //            $this->markTestSkipped( 'Record Create/Update Unpredictable Behaviour' );
        }
        $recOrig = ['alloggio' => 'case', 'lavoro' => 'mercato', 'vacanza' => 'mare'];
        $rec = new Record();
        $rec->setOData($recOrig);
        $result = $this->client->execute('recordCreate', ['cluster_id' => 9, 'record' => $rec]);
        $this->assertInstanceOf('\\PhpOrient\\Protocols\\Binary\\Data\\Record', $result);
        $this->assertEquals('#9:0', (string) $result->getRid());
        $this->assertEquals('9', $result->getRid()->cluster);
        $this->assertEquals('0', $result->getRid()->position);
        $recUp = ['alloggio' => 'home', 'lavoro' => 'bazar', 'vacanza' => 'sea'];
        $rec2 = new Record();
        $rec2->setOData($recUp);
        $rec2->setOClass('V');
        $updated = $this->client->execute('recordUpdate', ['cluster_id' => '9', 'cluster_position' => '0', 'record' => $rec2]);
        $this->assertInstanceOf('\\PhpOrient\\Protocols\\Binary\\Data\\Record', $result);
        $this->assertEquals('#9:0', (string) $updated->getRid());
        $this->assertEquals('9', $updated->getRid()->cluster);
        $this->assertEquals('0', $updated->getRid()->position);
        $this->assertTrue($updated->getVersion() > 0);
        $this->assertEquals((string) $rec2, (string) $updated);
        $load = $this->client->execute('recordLoad', ['rid' => $updated->getRid()])[0];
        $this->assertInstanceOf('\\PhpOrient\\Protocols\\Binary\\Data\\Record', $load);
        $this->assertEquals((string) $updated->getRid(), (string) $load->getRid());
        $this->assertEquals((string) $updated, (string) $load);
    }