Fixtures::clean PHP Method

clean() public method

public clean ( )
    function clean()
    {
        $classes = array('Address', 'Country', 'City', 'Profile', 'Company', 'Post', 'Comment', 'MapPoint');
        //Clean
        foreach ($classes as $class) {
            $query = "DROP CLASS " . $class;
            $this->client->post('/command/' . $this->dbname . '/sql/' . $query, array('Content-Type' => 'application/json'))->send();
        }
        return $this;
    }

Usage Example

Beispiel #1
0
        for ($i = 0; $i <= 5; $i++) {
            $this->client->post('/document/' . $this->dbname, $this->contentType, sprintf($templateComment, $i, $i))->send();
        }
        //Insert Post
        $templatePost = '{"@class": "Post", "id":%d,"title": "%d", "body": "Body %d", "comments":["#' . $this->Comment . ':3"] }';
        for ($i = 0; $i <= 5; $i++) {
            $this->client->post('/document/' . $this->dbname, $this->contentType, sprintf($templatePost, $i, $i, $i))->send();
        }
        $this->client->post('/document/' . $this->dbname, $this->contentType, '{"@class": "Post", "id":6,"title": "titolo 6", "body": "Body 6", "comments":["#' . $this->Comment . ':2"] }')->send();
        //Insert MapPoint
        $this->client->post('/document/' . $this->dbname, $this->contentType, '{"@class": "MapPoint", "x": "42.573968", "y": "13.203125" }')->send();
        $templatePerson = '{"@class": "PersonV", "name": "%s"}';
        foreach (['George', 'Cameron', 'Sydney'] as $name) {
            $this->client->post('/document/' . $this->dbname, $this->contentType, sprintf($templatePerson, $name))->send();
        }
        $templatePost = '{"@class": "PostV", "title": "%s"}';
        foreach (['Hello World', 'Welcome World', 'Another Post'] as $title) {
            $this->client->post('/document/' . $this->dbname, $this->contentType, sprintf($templatePost, $title))->send();
        }
        $likeE = 'CREATE EDGE LikedE FROM %s to %s';
        $this->client->post(sprintf('/command/%s/sql', $this->dbname), $this->contentType, sprintf($likeE, '#26:0', '#29:0'))->send();
        $followsE = 'CREATE EDGE FollowedE FROM %s to %s';
        $this->client->post(sprintf('/command/%s/sql', $this->dbname), $this->contentType, sprintf($followsE, '#26:0', '#26:1'))->send();
        $this->client->post(sprintf('/command/%s/sql', $this->dbname), $this->contentType, sprintf($followsE, '#26:2', '#26:1'))->send();
        $this->client->post(sprintf('/command/%s/sql', $this->dbname), $this->contentType, sprintf($followsE, '#26:1', '#26:0'))->send();
        return $this;
    }
}
$fixtures = new Fixtures('ODMTest', 'root', 'password');
$fixtures->clean()->create_classes()->load_fixtures();