public function testCount() { $oom = $this->mock('Doctrine\\ORM\\EntityManager'); $query = $this->mock(new Query($oom)); $oom->shouldReceive('createQuery')->once()->with('SELECT COUNT(object) FROM Foo\\Bar object')->andReturn($query); $query->shouldReceive('getSingleScalarResult')->once()->andReturn(5); $om = new ObjectManager($oom); $this->assertEquals(5, $om->count('Foo\\Bar')); }