From c46eee611f8f7c943aac89aad8882ae03dc71b70 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Sat, 9 Feb 2013 00:57:41 +0100 Subject: [PATCH] Added some Travis-CI tests --- .travis.yml | 23 +++++++++++++++++++++++ src/API/ServerAPI.php | 2 +- tests/BinaryRW.php | 15 +++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100644 tests/BinaryRW.php diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..5b377178d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +language: php + +php: + - 5.4 + - 5.5 + +matrix: + allow_failures: + - php: 5.5 + +before_script: + - sudo pecl install channel://pecl.php.net/pthreads-0.0.42 + +script: + - phpunit tests/ + +notifications: + email: false + irc: + channels: + - "irc.freenode.org#mcpedevs" + template: + "PocketMine-MP #%{build_number} %{commit}: %{message} (%{build_url}) \ No newline at end of file diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index a4fcb89bf..cd178a949 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -252,7 +252,7 @@ class ServerAPI{ if(!$this->config->exists("invisible")){ $this->config->set("invisible", false); } - if(is_object($this->server)){ + if($this->server instanceof PocketMinecraftServer){ $this->server->setType($this->getProperty("server-type")); $this->server->timePerSecond = $this->getProperty("time-per-second"); $this->server->invisible = $this->getProperty("invisible"); diff --git a/tests/BinaryRW.php b/tests/BinaryRW.php new file mode 100644 index 000000000..8a9f2e2b0 --- /dev/null +++ b/tests/BinaryRW.php @@ -0,0 +1,15 @@ +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"); + $item = Utils::readSlot("\x00\x09\x08\x00\x00"); + $this->assertTrue(($item instanceof Item) and $item->getID() === STILL_WATER and $item->count === 8 and $item->getMetadata() === 0, "Utils::readSlot"); + } +} \ No newline at end of file