Phalcon\Test\Unit\Mvc\CollectionTest::testShouldUseCorrectMongoId PHP Method

testShouldUseCorrectMongoId() public method

Tests Collection::findById
Since: 2016-07-24
Author: Serghei Iakovlev ([email protected])
    public function testShouldUseCorrectMongoId()
    {
        $this->specify('The Collection::findById does not return expected result', function () {
            $song = new Songs();
            $song->artist = 'Jo Blankenburg';
            $song->name = 'Valkyrie';
            $song->create();
            $mongoIdObject = $song->_id;
            expect(Songs::findById($mongoIdObject->__toString()))->isInstanceOf('\\Phalcon\\Mvc\\CollectionInterface');
            expect(Songs::findById($mongoIdObject))->isInstanceOf('\\Phalcon\\Mvc\\CollectionInterface');
            expect(Songs::findById('qwerty-1234'))->null();
            expect(Songs::findById('s'))->null();
            expect(Songs::findById(str_repeat('0', 25)))->null();
            expect(Songs::findById(''))->null();
            expect(Songs::findById(null))->null();
            expect(Songs::findById(false))->null();
        });
    }