<?php require_once __DIR__ . '/../../helper.php'; use Waffles\Test; use Koi\CLI; Test::group("Test if CLI applications can be created using Koi", function () { Test::add("Generate the correct CLI URI", function ($test) { $GLOBALS['argv'] = array('cli.php', 'hello world'); $cli_uri = CLI::uri(); $test->expects($cli_uri)->to()->equal("/hello/world/"); }); Test::add("Get the values of a set of options", function ($test) { CLI::set_opt(NULL, 'age', 'Get a person\'s age'); CLI::set_opt(NULL, 'n', 'Get the name of a person'); CLI::set_opt(NULL, 'd', 'Description'); $GLOBALS['argv'] = array('cli.php', 'hello', '--age=10', '-n', 'yorick', '-x', '-d', 'hello world'); $age = CLI::get_opt('age'); $name = CLI::get_opt('n'); $desc = CLI::get_opt('d'); $x = CLI::get_opt('x'); // -x Reverts to NULL as there's no value assigned to it. $test->expects($age)->to()->equal('10'); $test->expects($name)->to()->equal('yorick'); $test->expects($desc)->to()->equal('hello world'); $test->expects($x)->to()->be_type_of('NULL'); $test->expects($x)->to()->equal(NULL); }); Test::add("Get all options along with their values", function ($test) { CLI::set_opt(NULL, 'name', 'Enter your name'); $GLOBALS['argv'] = array('cli.php', 'hello', '--name', 'yorick'); $opts = CLI::opts();