From 27944ac13248198b262bdc881e35cf0098f23cc6 Mon Sep 17 00:00:00 2001 From: Pitchaya Boonsarngsuk Date: Wed, 19 Dec 2018 21:29:53 +0000 Subject: [PATCH] Framework --- src/Handlers.php | 19 +++++++++++++++++++ src/MessageHandler.php | 7 +++++++ src/entryPoint.php | 21 +++++++++++++++++++-- src/repl.php | 2 +- test/Test.php | 11 ++++++++--- 5 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 src/Handlers.php create mode 100644 src/MessageHandler.php diff --git a/src/Handlers.php b/src/Handlers.php new file mode 100644 index 0000000..89d0a40 --- /dev/null +++ b/src/Handlers.php @@ -0,0 +1,19 @@ +CanHandle($room_id, $msgid, $message)) { + return $handler->Handle($room_id, $msgid, $message); + } + } + return ; } \ No newline at end of file diff --git a/src/repl.php b/src/repl.php index 2b4d142..00fcbf0 100644 --- a/src/repl.php +++ b/src/repl.php @@ -12,6 +12,6 @@ do { $input = fread(STDIN, 80); // Read up to 80 characters or a newline $trimmed = trim($input); - echo '> ' , reply_user($room_id, $msg_id, $trimmed) , "\n"; + echo $msg_id, ' > ' , reply_user($room_id, $msg_id, $trimmed) , "\n"; $msg_id++; } while($trimmed !== "exit"); \ No newline at end of file diff --git a/test/Test.php b/test/Test.php index 92f65fe..b8fb36d 100644 --- a/test/Test.php +++ b/test/Test.php @@ -11,11 +11,16 @@ require '../src/entryPoint.php'; class Test extends TestCase { - public function testShouldReturnMessageID(): void + public function testShouldNotNULLMessageID0(): void { - $this->assertEquals( - '0', + $this->assertNotNull( reply_user('whatever', 0, 'whatever') ); } + public function testShouldNULLMessageID1(): void + { + $this->assertNull( + reply_user('whatever', 1, 'whatever') + ); + } }