public function testShouldGetRawCollection() { // Arrange $connPool = m::mock(Pool::class); $mapper = new DataMapper($connPool); $connection = m::mock(Connection::class); $collection = m::mock(Collection::class); $schema = m::mock(Schema::class); $schema->collection = 'foobar'; $mapper->setSchema($schema); $connection->defaultDatabase = 'grimory'; $connection->grimory = (object) ['foobar' => $collection]; // Expect $connPool->shouldReceive('getConnection')->once()->andReturn($connection); $connection->shouldReceive('getRawConnection')->andReturn($connection); // Act $result = $this->callProtected($mapper, 'getCollection'); // Assert $this->assertEquals($collection, $result); }