public function testCount() { /** * @see http://php.net/manual/en/mongocursor.count.php */ $mongoCursorMock = $this->getMockBuilder('\\MongoCursor')->disableOriginalConstructor()->getMock(); $mongoCursorMock->expects($this->atLeastOnce())->method('count')->with($this->equalTo(true))->will($this->returnValue(11)); $resultSet = new HydratingResultSet(); $resultSet->initialize($mongoCursorMock); $this->assertEquals(11, $resultSet->count()); }
public function setUp() { $mongoCollectionMock = $this->getMockBuilder('\\MongoCollection')->disableOriginalConstructor()->setMethods(['save', 'find', 'remove', 'insert', 'update', 'getName'])->getMock(); $this->mongoCollectionMock = $mongoCollectionMock; self::disableStrictErrors(); $mockProxy = new MongoCollectionMockProxy(); self::restoreErrorReportingLevel(); $mockProxy->__MongoCollectionMockProxy__setMock($mongoCollectionMock); $this->mockProxy = $mockProxy; $hydrator = new TransactionModelHydrator(); $resultSetPrototype = new HydratingResultSet(); $resultSetPrototype->setObjectPrototype($this->createTransactionEntityAsset()); $resultSetPrototype->setHydrator($hydrator); $this->transactionModel = new TransactionModel($mockProxy, $resultSetPrototype); $this->transactionModel->setHydrator($hydrator); $reflClass = new \ReflectionClass($this->transactionModel); $this->classRefl = $reflClass; $this->switchStateMethodRefl = $reflClass->getMethod('switchState'); $this->switchStateMethodRefl->setAccessible(true); }