Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test harness and JSON endpoint transport.

  • Loading branch information...
commit eb76849fac68912e3e2336c5195e449257b510e2 1 parent b3fa017
@jadell authored
View
22 LICENSE
@@ -0,0 +1,22 @@
+All project code is licensed under the MIT License
+http://www.opensource.org/licenses/mit-license.php
+
+Copyright (c) 2011 Josh Adell <josh.adell@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
6 lib/Everyman/Neo4j/Exception.php
@@ -0,0 +1,6 @@
+<?php
+namespace Everyman\Neo4j;
+
+class Exception extends \Exception
+{
+}
View
35 lib/Everyman/Neo4j/Transport.php
@@ -0,0 +1,35 @@
+<?php
+namespace Everyman\Neo4j;
+
+/**
+ * Class for communicating with an HTTP JSON endpoint
+ */
+class Transport
+{
+ protected $scheme = 'http';
+ protected $host = 'localhost';
+ protected $port = 7474;
+ protected $path = '/db/data/';
+
+ /**
+ * Set the host and port of the endpoint
+ *
+ * @param string $host
+ * @param integer $port
+ */
+ public function __construct($host='localhost', $port=7474)
+ {
+ $this->host = $host;
+ $this->port = $port;
+ }
+
+ /**
+ * Return the Neo4j REST endpoint
+ *
+ * @return string
+ */
+ public function getEndpoint()
+ {
+ return "{$this->scheme}://{$this->host}:{$this->port}{$this->path}";
+ }
+}
View
14 tests/bootstrap.php
@@ -0,0 +1,14 @@
+<?php
+function loaderTestAutoloader($sClass)
+{
+ $sLibPath = __DIR__.'/../lib/';
+ $sClassFile = str_replace('\\',DIRECTORY_SEPARATOR,$sClass).'.php';
+ $sClassPath = $sLibPath.$sClassFile;
+
+ if (file_exists($sClassPath)) {
+ require($sClassPath);
+ }
+}
+
+chdir(__DIR__.'/..');
+spl_autoload_register('loaderTestAutoloader');
View
5 tests/phpunit.xml
@@ -0,0 +1,5 @@
+<phpunit colors="true" bootstrap="./bootstrap.php">
+ <testsuite name="Neo4j PHP Test Results">
+ <directory>./unit</directory>
+ </testsuite>
+</phpunit>
View
2  tests/runtests
@@ -0,0 +1,2 @@
+cd `dirname $0`
+phpunit $@ .
View
20 tests/unit/lib/Everyman/Neo4j/TransportTest.php
@@ -0,0 +1,20 @@
+<?php
+namespace Everyman\Neo4j;
+
+class TransportTest extends \PHPUnit_Framework_TestCase
+{
+ protected $host = 'foo.com';
+ protected $port = 1234;
+
+ protected $transport = null;
+
+ public function setUp()
+ {
+ $this->transport = new Transport($this->host, $this->port);
+ }
+
+ public function testGetEndpoint_ReturnsCorrectEndpointUrl()
+ {
+ $this->assertEquals("http://{$this->host}:{$this->port}/db/data/", $this->transport->getEndpoint());
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.