From 4d53d07def431ef763d15c02785e749907067112 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Wed, 28 Aug 2013 15:24:18 +0200 Subject: [PATCH] Moved tests --- .travis.yml | 9 ++------- src/tests/ServerSuiteTest.php | 30 ++++++++++++++++++++++++++++++ src/tests/phpunit.xml | 6 ++++++ 3 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 src/tests/ServerSuiteTest.php create mode 100644 src/tests/phpunit.xml diff --git a/.travis.yml b/.travis.yml index 7e07f39a5..6c4cc8038 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,15 +5,10 @@ php: before_script: - pecl install channel://pecl.php.net/pthreads-0.0.44 - - git clone --depth=100 --quiet --branch=tests git://github.com/PocketMine/PocketMine-MP.git $(pwd)/tests/ script: - - phpunit tests/ + - phpunit src/tests/ notifications: email: false - webhooks: http://n.tkte.ch/h/214/wsNvmG43-ncxUVRrFPwSM-r0 - -branches: - except: - - tests \ No newline at end of file + webhooks: http://n.tkte.ch/h/214/wsNvmG43-ncxUVRrFPwSM-r0 \ No newline at end of file diff --git a/src/tests/ServerSuiteTest.php b/src/tests/ServerSuiteTest.php new file mode 100644 index 000000000..9389ac920 --- /dev/null +++ b/src/tests/ServerSuiteTest.php @@ -0,0 +1,30 @@ +assertTrue(true); + + $this->server->close(); + } + + public function testRead(){ + + //binary things + $this->assertTrue(Utils::readTriad("\x02\x01\x03") === 131331, "Utils::readTriad"); + $this->assertTrue(Utils::readInt("\xff\x02\x01\x03") === -16645885, "Utils::readInt"); + $this->assertTrue(abs(Utils::readFloat("\x49\x02\x01\x03") - 532496.1875) < 0.0001, "Utils::readFloat"); + $this->assertTrue(abs(Utils::readDouble("\x41\x02\x03\x04\x05\x06\x07\x08") - 147552.5024529) < 0.0001, "Utils::readDouble"); + $this->assertTrue(Utils::readLong("\x41\x02\x03\x04\x05\x06\x07\x08") === "4684309878217770760", "Utils::readLong"); + //PocketMine-MP server startup + require_once(dirname(__FILE__)."/../dependencies.php"); + require_once(FILE_PATH."/src/functions.php"); + require_once(FILE_PATH."/src/dependencies.php"); + $this->server = new ServerAPI(); + $this->assertTrue(is_integer($this->server->event("server.start", array($this, "hook")))); + $this->server->start(); + + kill(getmypid()); //Fix for ConsoleAPI being blocked + exit(0); + } +} \ No newline at end of file diff --git a/src/tests/phpunit.xml b/src/tests/phpunit.xml new file mode 100644 index 000000000..2fa40761e --- /dev/null +++ b/src/tests/phpunit.xml @@ -0,0 +1,6 @@ + + + + ./ + + \ No newline at end of file