Neos\Flow\Persistence\Doctrine\QueryResult::count PHP Method

count() public method

Returns the number of objects in the result
public count ( ) : integer
return integer The number of matching objects
    public function count()
    {
        if ($this->numberOfRows === null) {
            if (is_array($this->rows)) {
                $this->numberOfRows = count($this->rows);
            } else {
                $this->numberOfRows = $this->query->count();
            }
        }
        return $this->numberOfRows;
    }

Usage Example

 /**
  * @test
  */
 public function countCallsCountOnTheQueryOnlyOnce()
 {
     $this->query->expects($this->once())->method('count')->will($this->returnValue(321));
     $this->queryResult->count();
     $this->assertEquals(321, $this->queryResult->count());
 }