Boilerplate to use a Directus Instance to Build a Custom Website, Content will be Manage by Directus
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.6 KiB

5 years ago
  1. <?php
  2. /**
  3. * Flight: An extensible micro-framework.
  4. *
  5. * @copyright Copyright (c) 2012, Mike Cao <mike@mikecao.com>
  6. * @license MIT, http://flightphp.com/license
  7. */
  8. require_once 'vendor/autoload.php';
  9. require_once __DIR__.'/../flight/autoload.php';
  10. require_once __DIR__.'/classes/Hello.php';
  11. class MapTest extends PHPUnit_Framework_TestCase
  12. {
  13. /**
  14. * @var \flight\Engine
  15. */
  16. private $app;
  17. function setUp() {
  18. $this->app = new \flight\Engine();
  19. }
  20. // Map a closure
  21. function testClosureMapping(){
  22. $this->app->map('map1', function(){
  23. return 'hello';
  24. });
  25. $result = $this->app->map1();
  26. $this->assertEquals('hello', $result);
  27. }
  28. // Map a function
  29. function testFunctionMapping(){
  30. $this->app->map('map2', function(){
  31. return 'hello';
  32. });
  33. $result = $this->app->map2();
  34. $this->assertEquals('hello', $result);
  35. }
  36. // Map a class method
  37. function testClassMethodMapping(){
  38. $h = new Hello();
  39. $this->app->map('map3', array($h, 'sayHi'));
  40. $result = $this->app->map3();
  41. $this->assertEquals('hello', $result);
  42. }
  43. // Map a static class method
  44. function testStaticClassMethodMapping(){
  45. $this->app->map('map4', array('Hello', 'sayBye'));
  46. $result = $this->app->map4();
  47. $this->assertEquals('goodbye', $result);
  48. }
  49. // Unmapped method
  50. function testUnmapped() {
  51. $this->setExpectedException('Exception', 'doesNotExist must be a mapped method.');
  52. $this->app->doesNotExist();
  53. }
  54. }