Esempio n. 1
0
<?php

require_once __DIR__ . '/../src/kcmerrill/utility/checkpoints.php';
/*
 * Checkpoint name is simple_example. Because we didn't give a second param(the base dir)
 * The checkpoints will be stored in the current working directory.
 *
 */
$checkpoints = new kcmerrill\utility\checkpoints('simple_example');
//Create a checkpoint called 'step_one';
//All of STDOUT will be stored in <CWD>/simple_example/step_one.ckpt
//In this case, Welcome to Step 1!
$checkpoints->step_one(function () {
    echo 'Welcome to Step 1!';
});
//ect ..
$checkpoints->step_two(function () {
    echo 'Welcome to Step 2!';
});
$checkpoints->step_three(function () {
    echo 'Welcome to Step 3!';
});
$checkpoints->step_four(function () {
    echo 'Welcome to Step 4!';
});
/* Now, run this again, and you'll notice nothing will execute because the checkpoints exist.
 * Then, go and delete one of the checkpoints, and run it again ...
*/
Esempio n. 2
0
 public function testGeneralUse()
 {
     $checkpoint_name = 'kcmerrillwazhere';
     $checkpoints = new kcmerrill\utility\checkpoints($checkpoint_name);
     $this->assertEquals($checkpoint_name, $checkpoints->getName());
     $checkpoints->step_one(function () {
         echo 'Welcome to Step 1!';
     });
     $checkpoints->step_two(function () {
         echo 'Welcome to Step 2!';
     });
     $checkpoints->step_three(function () {
         echo 'Welcome to Step 3!';
     });
     $checkpoints->step_four(function () {
         echo 'Welcome to Step 4!';
     });
     $this->assertEquals('Welcome to Step 1!', file_get_contents($checkpoints->getFullFilePath('step_one')));
     $this->assertEquals('Welcome to Step 2!', file_get_contents($checkpoints->getFullFilePath('step_two')));
     $this->assertEquals('Welcome to Step 3!', file_get_contents($checkpoints->getFullFilePath('step_three')));
     $this->assertEquals('Welcome to Step 4!', file_get_contents($checkpoints->getFullFilePath('step_four')));
     $checkpoints->step_one(function () {
         echo 'This should not be executed, because step_one has already run!';
     });
     $this->assertEquals('Welcome to Step 1!', file_get_contents($checkpoints->getFullFilePath('step_one')));
 }