Sokil\Mongo\CursorTest::testFindOne PHP Method

testFindOne() public method

public testFindOne ( )
    public function testFindOne()
    {
        $this->collection->createDocument(array('someField' => 'A'))->save();
        $this->collection->createDocument(array('someField' => 'B'))->save();
        $documentId = $this->collection->createDocument(array('someField' => 'C'))->save()->getId();
        // find existed row
        $document = $this->collection->find()->where('someField', 'C')->findOne();
        $this->assertEquals($documentId, $document->getId());
        // find unexisted row
        $document = $this->collection->find()->where('some-unexisted-field', 'some-value')->findOne();
        $this->assertEmpty($document);
    }