diff --git a/src/PathMapper/PathMapper.php b/src/PathMapper/PathMapper.php deleted file mode 100644 index 1cc99bd..0000000 --- a/src/PathMapper/PathMapper.php +++ /dev/null @@ -1,101 +0,0 @@ -connection = $connection; - } - - /** - * {@inheritDoc} - */ - public function getFedoraPath($drupal_path) - { - $sql = "SELECT fedora FROM Gemini WHERE drupal = :path"; - $stmt = $this->connection->executeQuery( - $sql, - ['path' => urldecode($drupal_path)] - ); - $result = $stmt->fetch(); - - if (isset($result['fedora'])) { - return $result['fedora']; - } - - return null; - } - - /** - * {@inheritDoc} - */ - public function getDrupalPath($fedora_path) - { - $sql = "SELECT drupal FROM Gemini WHERE fedora = :path"; - $stmt = $this->connection->executeQuery( - $sql, - ['path' => urldecode($fedora_path)] - ); - $result = $stmt->fetch(); - - if (isset($result['drupal'])) { - return $result['drupal']; - } - - return null; - } - - /** - * {@inheritDoc} - */ - public function createPair($drupal_path, $fedora_path) - { - $this->connection->insert( - 'Gemini', - [ - 'drupal' => urldecode($drupal_path), - 'fedora' => urldecode($fedora_path), - ] - ); - } - - /** - * {@inheritDoc} - */ - public function deleteFromDrupalPath($drupal_path) - { - return $this->connection->delete( - 'Gemini', - ['drupal' => urldecode($drupal_path)] - ); - } - - /** - * {@inheritDoc} - */ - public function deleteFromFedoraPath($fedora_path) - { - return $this->connection->delete( - 'Gemini', - ['fedora' => urldecode($fedora_path)] - ); - } -} diff --git a/src/PathMapper/PathMapperInterface.php b/src/PathMapper/PathMapperInterface.php deleted file mode 100644 index 90adbe9..0000000 --- a/src/PathMapper/PathMapperInterface.php +++ /dev/null @@ -1,45 +0,0 @@ -prophesize(Statement::class); - $statement->fetch()->willReturn(['fedora' => 'foo']); - $statement = $statement->reveal(); - - $db = $this->prophesize(Connection::class); - $db->executeQuery(Argument::Any(), Argument::Any()) - ->willReturn($statement); - $db = $db->reveal(); - - $path_mapper = new PathMapper($db); - - $result = $path_mapper->getFedoraPath("bar"); - $this->assertTrue( - $result == 'foo', - "Expected 'foo', received $result" - ); - } - - public function testGetFedoraPathReturnsNullIfNotFound() - { - $prophecy = $this->prophesize(Statement::class); - $prophecy->fetch()->willReturn([]); - $statement = $prophecy->reveal(); - - $prophecy = $this->prophesize(Connection::class); - $prophecy->executeQuery(Argument::Any(), Argument::Any()) - ->willReturn($statement); - $db = $prophecy->reveal(); - - $path_mapper = new PathMapper($db); - - $result = $path_mapper->getFedoraPath("foo"); - $this->assertTrue( - $result === null, - "Expected null, received $result" - ); - } - - public function testGetDrupalPathReturnsResultOnSuccess() - { - $statement = $this->prophesize(Statement::class); - $statement->fetch()->willReturn(['drupal' => 'foo']); - $statement = $statement->reveal(); - - $db = $this->prophesize(Connection::class); - $db->executeQuery(Argument::Any(), Argument::Any()) - ->willReturn($statement); - $db = $db->reveal(); - - $path_mapper = new PathMapper($db); - - $result = $path_mapper->getDrupalPath("bar"); - $this->assertTrue( - $result == 'foo', - "Expected 'foo', received $result" - ); - } - - public function testGetDrupalPathReturnsNullIfNotFound() - { - $prophecy = $this->prophesize(Statement::class); - $prophecy->fetch()->willReturn([]); - $statement = $prophecy->reveal(); - - $prophecy = $this->prophesize(Connection::class); - $prophecy->executeQuery(Argument::Any(), Argument::Any()) - ->willReturn($statement); - $db = $prophecy->reveal(); - - $path_mapper = new PathMapper($db); - - $result = $path_mapper->getDrupalPath("foo"); - $this->assertTrue( - $result === null, - "Expected null, received $result" - ); - } -}