Phalcon\Test\Mvc\Model\EagerLoading\EagerLoadingTest::testShouldUseEagerLoadingAndDetectHasManyToMany PHP Method

testShouldUseEagerLoadingAndDetectHasManyToMany() public method

    public function testShouldUseEagerLoadingAndDetectHasManyToMany()
    {
        $rawly = Robot::findFirstById(1);
        $rawly->parts;
        $eagerly = Loader::fromModel(Robot::findFirstById(1), 'Parts');
        $this->assertTrue(property_exists($eagerly, 'parts'));
        $this->assertTrue(is_array($eagerly->parts));
        $this->assertSame(count($eagerly->parts), $rawly->parts->count());
        $getIds = function ($arr) {
            $ret = [];
            foreach ($arr as $r) {
                if (is_object($r)) {
                    $ret[] = $r->readAttribute('id');
                }
            }
            return $ret;
        };
        $this->assertEquals($getIds($this->resultSetToEagerLoadingEquivalent($rawly->parts)), $getIds($eagerly->parts));
    }