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

testShouldGetCollectionByUsingFindFirst() public method

Tests Collection::findFirst
Since: 2016-03-13
Author: Serghei Iakovlev ([email protected])
    public function testShouldGetCollectionByUsingFindFirst()
    {
        $this->specify("Collection::findFirst does not return expected result", function () {
            $song = Songs::findFirst();
            expect($song->artist)->equals('Radiohead');
            expect($song->name)->equals('Lotus Flower');
            $song = Songs::findFirst([['artist' => 'Massive Attack']]);
            expect($song->artist)->equals('Massive Attack');
            expect($song->name)->equals('Teardrop');
            $song = Songs::findFirst(['conditions' => ['name' => 'Paradise Circus']]);
            expect($song->artist)->equals('Massive Attack');
            expect($song->name)->equals('Paradise Circus');
            expect(Songs::findFirst([['artist' => 'Lana']]))->false();
            expect(Songs::findFirst(['conditions' => ['artist' => 'Lana']]))->false();
        });
    }