Exemplo n.º 1
0
/**
 *
 */
function paginate(\stdClass $i_gd, $i_count, &$o_perpage, &$o_page, &$o_totalPages, &$o_limit = null)
{
    $o_perpage = within(@$i_gd->pp, 3, 25);
    $o_page = max(@$i_gd->page, 1);
    $o_totalPages = ceil($i_count / $o_perpage) ?: 1;
    $o_limit = ($o_page - 1) * $o_perpage . ',' . $o_perpage;
}
Exemplo n.º 2
0
$sampleTopic = (include __DIR__ . '/../examples/topic-calculus.php');
$expectedOutput = <<<OUTPUT
topics: 1
features: 2
assertions: 5

FAILED: calculus: addition adds two numbers
Expected values to be equal, instead got:
--- Actual
+++ Expected
@@ @@
-2
+3

FAILED: calculus: addition is difficult
Expected values to be equal, instead got:
--- Actual
+++ Expected
@@ @@
-6
+33

FAILED: calculus: subtraction looks strange
Expected value to be false

OUTPUT;
return within("integration", describe("output from complete suite", it("renders everything we need to know", function () use($expectedOutput, $sampleTopic) {
    $renderedOutput = renderOutput(testResults([$sampleTopic]));
    return $renderedOutput === $expectedOutput;
})));
Exemplo n.º 3
0
<?php

function bad()
{
    throw new Exception('Something');
}
$sampleTopic = within("foo", describe("bar", it("throws an exception", function () {
    return expect(bad(), toBe('good'));
})));
return within("omikron", describe("assertion", it("catches exceptions in callable", function () use($sampleTopic) {
    try {
        $renderedOutput = renderOutput(testResults([$sampleTopic]));
    } catch (Exception $e) {
        $renderedOutput = '';
    }
    $outputContainsError = strpos($renderedOutput, 'FAILED') !== false && strpos($renderedOutput, 'Exception: Something in') !== false && strpos($renderedOutput, 'Call stack:') !== false;
    return expect($outputContainsError, toBeTrue());
})));
Exemplo n.º 4
0
<?php

return within("calculus", describe("addition", it("adds two numbers", function () {
    return expect(1 + 1, toBe(3));
}), it("is difficult", function () {
    return expect(3 + 3, toBe(33));
}), it("adds three numbers", function () {
    return expect(1 + 1 + 1, toBe(3));
})), describe("subtraction", it("looks strange", function () {
    return expect(true, toBeFalse());
}), it("subtracts two numbers", function () {
    return expect(3 - 2, notToBe(5));
})));
Exemplo n.º 5
0
/**
 * Deploy start, prepare deploy directory
 */
task('deploy:start', function () {
    cd('~');
    run("if [ ! -d {{deploy_path}} ]; then mkdir -p {{deploy_path}}; fi");
    cd('{{deploy_path}}');
})->setPrivate();
/**
 * Clear cache and restart backend services
 */
task('backend:restart', function () {
    within('{{deploy_path}}/current', function () {
        // TODO: stop all services
        // Clear map files
        run("redis-cli -h {{redis.host}} -p {{redis.port}} -n {{redis.db}} --raw keys \"{{app.prefix}}cake_core_file_map\" | xargs redis-cli -h {{redis.host}} -p {{redis.port}} -n {{redis.db}} del");
        // TODO: clear cache
        run('Console/cake cache clear -f 1');
        // TODO: start all service
    });
})->desc('Restart backend service for your system');
/**
 * Main task
 */
task('deploy', ['deploy:start', 'deploy:prepare', 'deploy:release', 'deploy:update_code', 'deploy:shared', 'deploy:writable', 'deploy:vendors', 'deploy:symlink', 'cleanup', 'backend:restart'])->desc('Deploy your project');
after('deploy', 'success');
/**
 * Load stage and list server
 */
foreach (glob(__DIR__ . '/stage/*.php') as $filename) {
    include $filename;
}