Youshido\Tests\Library\Relay\ArrayConnectionTest::testConnectionDefinition PHP Method

testConnectionDefinition() public method

    public function testConnectionDefinition()
    {
        $data = ['a', 'b', 'c', 'd', 'e'];
        $edges = [];
        foreach ($data as $key => $item) {
            $edges[] = ArrayConnection::edgeForObjectWithIndex($item, $key);
        }
        $this->assertEquals(['edges' => $edges, 'pageInfo' => ['startCursor' => $edges[0]['cursor'], 'endCursor' => $edges[count($edges) - 1]['cursor'], 'hasPreviousPage' => false, 'hasNextPage' => false]], ArrayConnection::connectionFromArray($data));
        $this->assertEquals(['edges' => array_slice($edges, 0, 2), 'pageInfo' => ['startCursor' => $edges[0]['cursor'], 'endCursor' => $edges[1]['cursor'], 'hasPreviousPage' => false, 'hasNextPage' => true]], ArrayConnection::connectionFromArray($data, ['first' => 2, 'last' => 4]));
    }