Sample test
This commit is contained in:
14
.idea/php-test-framework.xml
generated
Normal file
14
.idea/php-test-framework.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="PhpTestFrameworkVersionCache">
|
||||||
|
<tools_cache>
|
||||||
|
<tool tool_name="PHPUnit">
|
||||||
|
<cache>
|
||||||
|
<versions>
|
||||||
|
<info id="Local" version="6.5.13" />
|
||||||
|
</versions>
|
||||||
|
</cache>
|
||||||
|
</tool>
|
||||||
|
</tools_cache>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
9
.idea/php.xml
generated
Normal file
9
.idea/php.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="PhpProjectSharedConfiguration" php_language_level="7.1" />
|
||||||
|
<component name="PhpUnit">
|
||||||
|
<phpunit_settings>
|
||||||
|
<PhpUnitSettings load_method="PHPUNIT_PHAR" custom_loader_path="" phpunit_phar_path="$PROJECT_DIR$/../php-7.3.0-Win32-VC15-x64/phpunit-6.5.13.phar" />
|
||||||
|
</phpunit_settings>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Placeholder Globals
|
// Placeholder Globals
|
||||||
$userid = 0;
|
$userid = 0;
|
||||||
$room_lang = "th";
|
$room_lang = "th";
|
||||||
$is_admin = false;
|
$is_admin = false;
|
||||||
define("BLUE_ROOM", 12345);
|
define("BLUE_ROOM", 12345);
|
||||||
define("RED_ROOM", 67890);
|
define("RED_ROOM", 67890);
|
||||||
define("INTER_ROOM", 111213);
|
define("INTER_ROOM", 111213);
|
||||||
|
|
||||||
// randomorg($start,$end);
|
// randomorg($start,$end);
|
||||||
|
|
||||||
function reply_user($room_id, $msgid, $message)
|
function reply_user($room_id, $msgid, $message) : string
|
||||||
{
|
{
|
||||||
return $msgid;
|
return $msgid;
|
||||||
}
|
}
|
||||||
32
src/repl.php
32
src/repl.php
@@ -1,17 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
require 'entryPoint.php';
|
require 'entryPoint.php';
|
||||||
if(!defined("STDIN")) {
|
if(!defined("STDIN")) {
|
||||||
define("STDIN", fopen('php://stdin','r'));
|
define("STDIN", fopen('php://stdin','r'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$room_id = BLUE_ROOM;
|
$room_id = BLUE_ROOM;
|
||||||
$msg_id = 0;
|
$msg_id = 0;
|
||||||
|
|
||||||
echo "Starting test REPL\n";
|
echo "Starting test REPL\n";
|
||||||
do {
|
do {
|
||||||
$input = fread(STDIN, 80); // Read up to 80 characters or a newline
|
$input = fread(STDIN, 80); // Read up to 80 characters or a newline
|
||||||
$trimmed = trim($input);
|
$trimmed = trim($input);
|
||||||
|
|
||||||
echo '> ' , reply_user($room_id, $msg_id, $trimmed) , "\n";
|
echo '> ' , reply_user($room_id, $msg_id, $trimmed) , "\n";
|
||||||
$msg_id++;
|
$msg_id++;
|
||||||
} while($trimmed !== "exit");
|
} while($trimmed !== "exit");
|
||||||
21
test/Test.php
Normal file
21
test/Test.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: Brian
|
||||||
|
* Date: 19/12/2018
|
||||||
|
* Time: 21:00
|
||||||
|
*/
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
require '../src/entryPoint.php';
|
||||||
|
|
||||||
|
class Test extends TestCase
|
||||||
|
{
|
||||||
|
public function testShouldReturnMessageID(): void
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
'0',
|
||||||
|
reply_user('whatever', 0, 'whatever')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user