Fhaculty\Graph\Tests\Set\BaseVerticesTest::testOrderByGroup PHP Method

testOrderByGroup() public method

public testOrderByGroup ( )
    public function testOrderByGroup()
    {
        $graph = new Graph();
        $graph->createVertex()->setGroup(1);
        $graph->createVertex()->setGroup(100);
        $graph->createVertex()->setGroup(5);
        $graph->createVertex()->setGroup(100);
        $graph->createVertex()->setGroup(100);
        $graph->createVertex()->setGroup(2);
        $biggest = $graph->createVertex()->setGroup(200);
        $vertices = $graph->getVertices();
        $verticesOrdered = $vertices->getVerticesOrder(Vertices::ORDER_GROUP);
        $this->assertInstanceOf('Fhaculty\\Graph\\Set\\Vertices', $verticesOrdered);
        $this->assertEquals(1, $verticesOrdered->getVertexFirst()->getGroup());
        $this->assertEquals(200, $verticesOrdered->getVertexLast()->getGroup());
        $this->assertSame($biggest, $verticesOrdered->getVertexLast());
        $this->assertSame($biggest, $vertices->getVertexOrder(Vertices::ORDER_GROUP, true));
        $sumgroups = function (Vertex $vertex) {
            return $vertex->getGroup();
        };
        $this->assertSame(508, $vertices->getSumCallback($sumgroups));
        $this->assertSame(508, $verticesOrdered->getSumCallback($sumgroups));
    }