Sokil\Mongo\ExpressionTest::testWhereNotEmpty PHP Method

testWhereNotEmpty() public method

public testWhereNotEmpty ( )
    public function testWhereNotEmpty()
    {
        // null field
        $this->collection->createDocument(array('param' => null))->save();
        // empty array field
        $this->collection->createDocument(array('param' => array()))->save();
        // empty string field
        $this->collection->createDocument(array('param' => ''))->save();
        // NOT EMPTY FIELD
        $documentId = $this->collection->createDocument(array('param' => 'value'))->save()->getId();
        // unexisted field
        $this->collection->createDocument(array('fieldName' => 'value'))->save();
        // find all rows
        $documents = $this->collection->find()->whereNotEmpty('param')->findAll();
        $this->assertNotEmpty($documents);
        $this->assertEquals(1, count($documents));
        $document = current($documents);
        $this->assertEquals($documentId, $document->getId());
    }