RedUNIT\Blackhole\Import::testImportFromAndTainted PHP Method

testImportFromAndTainted() public method

Test import from and tainted.
public testImportFromAndTainted ( ) : void
return void
    public function testImportFromAndTainted()
    {
        testpack('Test importFrom() and Tainted');
        $bean = R::dispense('bean');
        R::store($bean);
        $bean->name = 'abc';
        asrt($bean->getMeta('tainted'), TRUE);
        R::store($bean);
        asrt($bean->getMeta('tainted'), FALSE);
        $copy = R::dispense('bean');
        R::store($copy);
        $copy = R::load('bean', $copy->id);
        asrt($copy->getMeta('tainted'), FALSE);
        $copy->import(array('name' => 'xyz'));
        asrt($copy->getMeta('tainted'), TRUE);
        $copy->setMeta('tainted', FALSE);
        asrt($copy->getMeta('tainted'), FALSE);
        $copy->importFrom($bean);
        asrt($copy->getMeta('tainted'), TRUE);
        testpack('Test basic import() feature.');
        $bean = new OODBBean();
        $bean->import(array("a" => 1, "b" => 2));
        asrt($bean->a, 1);
        asrt($bean->b, 2);
        $bean->import(array("a" => 3, "b" => 4), "a,b");
        asrt($bean->a, 3);
        asrt($bean->b, 4);
        $bean->import(array("a" => 5, "b" => 6), " a , b ");
        asrt($bean->a, 5);
        asrt($bean->b, 6);
        $bean->import(array("a" => 1, "b" => 2));
        testpack('Test inject() feature.');
        $coffee = R::dispense('coffee');
        $coffee->id = 2;
        $coffee->liquid = 'black';
        $cup = R::dispense('cup');
        $cup->color = 'green';
        // Pour coffee in cup
        $cup->inject($coffee);
        // Do we still have our own property?
        asrt($cup->color, 'green');
        // Did we pour the liquid in the cup?
        asrt($cup->liquid, 'black');
        // Id should not be transferred
        asrt($cup->id, 0);
    }