test_base.php 878 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. require_once 'base.php';
  3. use webbasics\Base;
  4. class BaseExtension extends Base {
  5. function __construct($foo, $bar) {
  6. $this->foo = $foo;
  7. $this->bar = $bar;
  8. }
  9. }
  10. class BaseTest extends PHPUnit_Framework_TestCase {
  11. function test_create() {
  12. $this->assertEquals(BaseExtension::create('a', 'b'), new BaseExtension('a', 'b'));
  13. }
  14. function test_asprintf() {
  15. $this->assertEquals(webbasics\asprintf('%(foo) baz', array('foo' => 'bar')), 'bar baz');
  16. $this->assertEquals(webbasics\asprintf('%(foo) baz %(foo)',
  17. array('foo' => 'bar')), 'bar baz bar');
  18. $this->assertEquals(webbasics\asprintf('%(bar) baz %(foo)',
  19. array('foo' => 'bar', 'bar' => 'foobar')), 'foobar baz bar');
  20. }
  21. function test_path_with_slash() {
  22. $this->assertEquals(Base::path_with_slash('dirname'), 'dirname/');
  23. $this->assertEquals(Base::path_with_slash('dirname/'), 'dirname/');
  24. }
  25. }
  26. ?>