コード例 #1
0
ファイル: web.php プロジェクト: noccy80/lepton-ng
<?php

using('lunit.*');
class LeptonWebTests extends LunitCase
{
    /**
     * @description Parsing URLs and setting properties
     */
    function url()
    {
        using('lepton.web.url');
        $u = new url('http://www.google.com?foo=bar');
        $u->setParameter('baz', 'bin');
        $this->assertEquals($u->toString(), 'http://www.google.com?foo=bar&baz=bin');
    }
    /**
     * @description Service Discovery
     */
    function discover()
    {
        using('lepton.net.httprequest');
        using('lepton.web.discovery');
        $d = Discovery::discover('http://127.0.0.1');
        $this->assertNotNull($d);
    }
}
Lunit::register('LeptonWebTests');
コード例 #2
0
ファイル: data.php プロジェクト: noccy80/lepton-ng
        $this->assertEquals($ds->getCount(), 2);
        $this->ds = $ds;
    }
    /**
     * @description Testing native pie chart implementation
     */
    function piechart()
    {
        $pc = new PieChart(400, 400);
        $this->assertNotNull($pc);
        $pc->setData($this->ds);
        $c = $pc->render();
        $this->assertEquals($c->width, 400);
        $this->assertEquals($c->height, 400);
    }
    /**
     * @description Testing Google pie chart implementation
     */
    function gpiechart()
    {
        $this->explicitFail('Not Implemented!');
        $pc = new GPieChart(400, 400);
        $this->assertNotNull($pc);
        $pc->setData($this->ds);
        $c = $pc->render();
        $this->assertEquals($c->width, 400);
        $this->assertEquals($c->height, 400);
    }
}
Lunit::register('LeptonDataTests');
コード例 #3
0
ファイル: delegates.php プロジェクト: noccy80/lepton-ng
        $this->results[] = $word;
    }
    /**
     * @description Creating delegate chain
     */
    function delegatecreate()
    {
        $this->delegate = new Delegate();
        $this->assertNotNull($this->delegate);
    }
    /**
     * @description Attaching delegates to chain
     */
    function delegateattach()
    {
        $this->delegate->addDelegate(array(&$this, '_dlgcb'));
        $this->delegate->addDelegate(array(&$this, '_dlgcb'));
    }
    /**
     * @description Calling delegate
     */
    function delegatecall()
    {
        $this->delegate->call("foo");
        $this->assertTrue(count($this->results) == 2);
        $this->assertEquals($this->results[0], "foo");
        $this->assertEquals($this->results[0], $this->results[1]);
    }
}
Lunit::register('LeptonDelegatesTests');
コード例 #4
0
ファイル: base.php プロジェクト: noccy80/lepton-ng
     */
    function testfmt()
    {
        $this->assertEquals(__fmt(array('foo%s')), 'foo%s');
        $this->assertEquals(__fmt(array('foo%s', 'bar')), 'foobar');
    }
    /**
     * @description __filepath() and __fileext() shorthands
     */
    function filepaths()
    {
        $this->assertEquals(__fileext('/foo/bar.baz'), 'baz');
        $this->assertEquals(__filepath('/foo/bar.baz'), '/foo');
    }
    /**
     * @description file_find() to locate file with globbing
     */
    function filefind()
    {
        $this->assertEquals(file_find(base::basePath(), 'defaults.php'), base::basePath() . 'sys/defaults.php');
    }
    /**
     * @description file_find() on a bad path returning null
     */
    function filefindbaddir()
    {
        $this->assertNull(file_find('/foo/bar', 'baz'));
    }
}
Lunit::register('LeptonBaseTests');
コード例 #5
0
ファイル: i18n.php プロジェクト: noccy80/lepton-ng
{
    /**
     * @description Setting languages
     */
    function setlanguage()
    {
        intl::setLanguage('sv');
        $this->assertEquals(intl::getLanguage(), 'sv');
        $this->assertEquals(intl::getFullLanguage(), 'sv');
        intl::setLanguage('en-gb');
        $this->assertEquals(intl::getLanguage(), 'en');
        $this->assertEquals(intl::getRegion(), 'gb');
        $this->assertEquals(intl::getFullLanguage(), 'en-gb');
    }
    /**
     * @description Setting bad language throws exception
     */
    function setbadlanguage()
    {
        intl::setLanguage('sv');
        try {
            intl::setLanguage('swe');
        } catch (Exception $e) {
            $this->assertEquals(intl::getLanguage(), 'sv');
            return;
        }
        $this->explicitFail('No exception thrown');
    }
}
Lunit::register('LeptonInternationalizationTests');
コード例 #6
0
ファイル: filesystem.php プロジェクト: noccy80/lepton-ng
     * @description Filesystem Factory test (FsObject)
     */
    function factory_test()
    {
        $f = FsObject::get(base::appPath());
        $this->assertNotNull($f);
        $this->assertEquals(typeof($f), 'FsDirectory');
    }
    function paths()
    {
        $f = FsObject::get(base::appPath());
        $path = $f->getDirname();
        $this->assertNotNull($path);
    }
    function usage()
    {
        $f = FsObject::get(base::appPath());
        $usage = $f->getDiskUsage(true);
        $this->assertNotNull($usage);
        $this->assertEquals(typeof($usage), 'array');
    }
    function joininigpaths()
    {
        $f = FsObject::get(base::appPath());
        $p1 = $f->joinPath('foo/bar');
        $p2 = $f->joinPath(array('foo', 'bar'));
        $this->assertEquals($p1, $p2);
    }
}
Lunit::register('LeptonFsTests');
コード例 #7
0
ファイル: graphics.php プロジェクト: noccy80/lepton-ng
        }
        $tf = $this->getTempFile('.png');
        $this->assertNotNull($this->canvas);
        $this->canvas->save($tf);
        $im = new ImagickImage($tf);
        $this->assertNotNull($im);
    }
    /**
     * @description Screen capture with Screenshot() class.
     * @repeat 5
     */
    function screenshot()
    {
        unset($this->canvas);
        $this->canvas = new Screenshot();
        $this->assertNotNull($this->canvas);
    }
    /**
     * @description Verifying properties of canvas
     */
    function screenshotprops()
    {
        if (!isset($this->canvas)) {
            $this->skip();
        }
        $this->assertTrue($this->canvas->width > 0);
        $this->assertTrue($this->canvas->height > 0);
    }
}
Lunit::register('LeptonCanvasTests');
コード例 #8
0
ファイル: streams.php プロジェクト: noccy80/lepton-ng
        $this->rw = new Stream($this->fn, 'r');
        $this->assertNotNull($this->rw);
    }
    /**
     * @description Reading data from stream
     */
    function readdata()
    {
        $data = $this->rw->gets();
        $this->assertEquals($data, 'Hello World!');
    }
    /**
     * @description Seeking, telling, and reading again
     */
    function readseek()
    {
        $this->rw->seek(0);
        $this->assertEquals($this->rw->tell(), 0);
        $data = $this->rw->gets();
        $this->assertEquals($data, 'Hello World!');
    }
    /**
     * @description Closing stream
     */
    function readclose()
    {
        unset($this->rw);
    }
}
Lunit::register('LeptonStreamsTest');
コード例 #9
0
ファイル: memcached.php プロジェクト: noccy80/lepton-ng
<?php

using('lunit.*');
class LeptonMemcachedTests extends LunitCase
{
    function __construct()
    {
        using('lepton.utils.cache');
    }
    function setcacheitems()
    {
        cache::set('foo', 'bar', '1m');
    }
    function hitcacheitem()
    {
        $r = cache::get('foo');
        $this->assertNotNull($r);
    }
    function hitfailcacheitem()
    {
        try {
            $r = cache::get('bar');
        } catch (CacheException $e) {
        }
    }
}
Lunit::register('LeptonMemcachedTests');
コード例 #10
0
ファイル: containers.php プロジェクト: noccy80/lepton-ng
            return;
        }
        $this->assertTrue(false);
    }
    /**
     * @description Testing incomplete BasicContainer
     */
    function ibasiccontainer()
    {
        try {
            $c1 = new IncompleteTestContainer();
            $this->assertTrue(false);
        } catch (Exception $e) {
            $this->assertTrue(true);
            return;
        }
        $this->assertTrue(false);
    }
    function basiclist()
    {
        $l = new BasicList();
        $l->push('Hello World');
        $l['foo'] = 'Bar';
        $this->assertEquals($l['foo'], 'Bar');
        $this->assertEquals($l->pop(), 'Bar');
        $this->assertEquals($l->pop(), 'Hello World');
        $this->assertEquals($l->pop(), null);
    }
}
Lunit::register('LeptonContainersTest');
コード例 #11
0
ファイル: optionset.php プロジェクト: noccy80/lepton-ng
        $this->assertEquals($this->os->xyzzy, null);
    }
    /**
     * @description Accessing via properties with defaults
     */
    function opttestdefaults()
    {
        $this->assertEquals($this->osd->foo, 'bar');
        $this->assertEquals($this->osd->xyzzy, 'omg');
    }
    /**
     * @description Accessing via get() without defaults
     */
    function opttestgetclean()
    {
        $this->assertEquals($this->os->get('foo'), 'bar');
        $this->assertEquals($this->os->get('xyzzy'), null);
        $this->assertEquals($this->os->get('xyzzy', 'omg'), 'omg');
    }
    /**
     * @description Accessing via properties with defaults
     */
    function opttestgetdefaults()
    {
        $this->assertEquals($this->osd->get('foo'), 'bar');
        $this->assertEquals($this->osd->get('xyzzy'), 'omg');
        $this->assertEquals($this->osd->get('xyzzy', 'xing'), 'xing');
    }
}
Lunit::register('LeptonOptionsetTests');
コード例 #12
0
ファイル: crypto.php プロジェクト: noccy80/lepton-ng
    /**
     * @description Twofish Cryptography Implementation
     */
    function twofishcrypto()
    {
        $c = new CryptoCipher(MCRYPT_TWOFISH, 'hello');
        $e = $c->encrypt('helloworld');
        $this->assertEquals($e, 'uIfx79ilnvRVY5RT/znzXA==');
        $this->assertEquals($c->decrypt($e), 'helloworld');
    }
    /**
     * @description DES Cryptography Implementation
     */
    function descrypto()
    {
        $c = new CryptoCipher(MCRYPT_DES, 'hello');
        $e = $c->encrypt('helloworld');
        $this->assertEquals($e, 'q8dBduudWGAuIw4LPXMCFQ==');
        $this->assertEquals($c->decrypt($e), 'helloworld');
    }
    /**
     * @description Generate UUID V4
     */
    function uuid_v4()
    {
        $uuid = uuid::v4();
        $this->assertEquals(strlen($uuid), uuid::LENGTH);
    }
}
Lunit::register('LeptonCryptoTests');
コード例 #13
0
ファイル: captcha.php プロジェクト: noccy80/lepton-ng
        using('lepton.mvc.session');
    }
    /**
     * @description Generating a new captcha
     */
    function testgenerate()
    {
        config('lepton.captcha.font', 'FreeSans.ttf');
        $this->captchaid = captcha::generate();
        $this->assertNotNull($this->captchaid);
        $this->captchatext = captcha::getstring($this->captchaid);
        $this->assertNotNull($this->captchatext);
    }
    /**
     * @description Displaying/saving captcha
     * @repeat 20
     */
    function display()
    {
        captcha::display($this->captchaid, $this->getTempFile('png'));
    }
    /**
     * @description Validating captcha string
     */
    function validate()
    {
        $this->assertTrue(captcha::verify($this->captchatext, $this->captchaid));
    }
}
Lunit::register('LeptonCaptchaTests');
コード例 #14
0
ファイル: prefs.php プロジェクト: noccy80/lepton-ng
     */
    function dbprefs()
    {
        if (!config::has('lepton.db.default')) {
            $this->skip();
        }
        $tf = $this->getTempFile();
        $s = new DbPrefs('prefstest');
        $this->assertNotNull($s);
        $s->foo = 'bar';
        unset($s);
        $s = new DbPrefs('prefstest');
        $this->assertNotNull($s);
        $this->assertEquals($s->foo, 'bar');
        $s->destroy();
        unset($s);
        // unlink('/tmp/jsonprefs.tmp');
    }
    /**
     * @description Array-based storage (Optionset)
     */
    function arrayprefs()
    {
        $s = new ArrayPrefs(array('foo' => 'bar'));
        $this->assertEquals($s->foo, 'bar');
        $this->assertEquals($s->get('foo'), 'bar');
        $this->assertEquals($s->get('bar', 'baz'), 'baz');
    }
}
Lunit::register('LeptonPrefsTests');
コード例 #15
0
ファイル: base.php プロジェクト: noccy80/lepton-ng
<?php

/**
 * @description Base tests for Lepton Application Platform
 */
class BaseTests extends LunitCase
{
    /**
     * @description Simple test
     */
    function simple()
    {
        $this->assertTrue(false);
    }
}
Lunit::register('BaseTests');
コード例 #16
0
ファイル: content.php プロジェクト: noccy80/lepton-ng
ContentManager::registerProvider(new DummyContentProvider());
ContentManager::registerExtension(new DummyContentExtension());
/**
 * @description Content Wrappers
 */
class LeptonContentTests extends LunitCase
{
    private $co = null;
    function __construct()
    {
    }
    /**
     * @description Testing provider for namespace dummy
     */
    function providertest()
    {
        $this->co = ContentManager::get('dummy:hello-world');
        $this->assertNotNull($this->co);
        $this->assertEquals($this->co->getHtml(), 'hello-world');
    }
    /**
     * @description Testing extension via dummy->reverse()
     */
    function extensiontest()
    {
        $this->assertNotNull($this->co);
        $this->assertEquals($this->co->dummy->reverse(), 'dlrow-olleh');
    }
}
Lunit::register('LeptonContentTests');
コード例 #17
0
ファイル: vartypes.php プロジェクト: noccy80/lepton-ng
<?php

using('lunit.*');
class LeptonVartypeTest extends LunitCase
{
    function stringtest()
    {
        $s = vartype::string()->required()->defaultvalue('foo');
        $this->assertTrue($s->getRequired());
        $this->assertEquals($s->getDefault(), 'foo');
    }
    function floattest()
    {
        $s = vartype::float()->nullable()->defaultvalue('foo');
        $this->assertFalse($s->getRequired());
        $this->assertEquals($s->getDefault(), 'foo');
    }
}
Lunit::register('LeptonVartypeTest');
コード例 #18
0
ファイル: ipc.php プロジェクト: noccy80/lepton-ng
        $this->qfn = $this->getTempFile();
        $this->queue = new MessageQueue($this->qfn);
        $this->assertNotNull($this->queue);
    }
    /**
     * @description MessageQueue: Posting message to queue
     * @repeat 50
     */
    function queuepostmessage()
    {
        $this->queue->push(1, new MessageEnvelope('lepton.test', array('foo' => 'bar')));
    }
    /**
     * @description MessageQueue: Reading message from queue
     * @repeat 50
     */
    function queuegetmessage()
    {
        $message = $this->queue->pop(1);
        $this->assertEquals($message->foo, 'bar');
    }
    /**
     * @description MessageQueue: Destroy queue
     */
    function destroyqueue()
    {
        $this->queue->destroy();
    }
}
Lunit::register('LeptonIpcTests');
コード例 #19
0
ファイル: mutex.php プロジェクト: noccy80/lepton-ng
            $this->assertTrue(true);
            return;
        }
        $this->assertTrue(false);
    }
    /**
     * @description Releasing lock through unset()
     */
    function mutexrelease()
    {
        unset($this->mutex);
        $this->assertTrue(true);
    }
    /**
     * @description Releasing lock through mutex->release()
     */
    function mutexreleasemtd()
    {
        $m = new Mutex('lunitlock', 100);
        $m->release();
    }
    /**
     * @description Cleaning up locks
     */
    function cleanup()
    {
        mutex::void();
    }
}
Lunit::register('LeptonMutexTest');