Mongolid\DataMapper\DataMapper::setSchema PHP Метод

setSchema() публичный Метод

Set a Schema object that describes an Entity in MongoDB.
public setSchema ( Schema $schema )
$schema Mongolid\Schema\Schema
    public function setSchema(Schema $schema)
    {
        $this->schema = $schema;
    }

Usage Example

Пример #1
0
 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);
 }