public function setUp()
 {
     $this->connection = $this->createMock(CsvDataGateway::class);
     $this->connection->expects($this->any())->method('getAll')->with('articles')->willReturn(array_values($this->articles));
     parent::setUp();
     $this->dataMapper = new CsvDataMapper($this->connection, Article::class, 'articles', $this->entityRegistry);
 }
 /**
  * Rolls back the current transaction, as initiated by beginTransaction().
  *
  * @return  void
  * @throws  OrmException  on failure.
  */
 public function rollBack()
 {
     try {
         $this->gateway->rollBack();
     } catch (\RuntimeException $e) {
         throw new OrmException("Unable to start transaction.\n" . $e->getMessage(), 0, $e);
     }
 }
 /**
  * Fetch the entities
  *
  * @param   int $count The number of matching entities to retrieve
  * @param   int $start The index of the first entity to retrieve
  *
  * @return  array
  */
 public function getItems($count = null, $start = 0)
 {
     $matches = $this->gateway->getAll($this->table);
     $matches = $this->applyConditions($matches);
     $matches = $this->applyOrdering($matches);
     if (!empty($this->columns)) {
         $result = $this->applyColumns($matches);
     } else {
         $result = $this->castToEntity($matches);
     }
     return array_slice($result, $start, $count);
 }
 /**
  * Gets the schema manager
  *
  * @return \Doctrine\DBAL\Schema\AbstractSchemaManager|null
  */
 public function getSchemaManager()
 {
     if (method_exists($this->connection, 'getSchemaManager')) {
         return $this->connection->getSchemaManager();
     }
     return null;
 }
 /**
  * delete() delegates call to connection
  */
 public function testDelete()
 {
     $this->connection->expects($this->once())->method('delete')->willReturn(1);
     $this->dataMapper->delete(new Article());
 }
Example #6
0
 /**
  * Delete an entity.
  *
  * @param   object $entity The entity to sanitise
  *
  * @return  void
  */
 public function delete($entity)
 {
     $this->gateway->delete($this->tableName, $this->builder->reduce($entity), $this->getIdentifier($entity));
 }