<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'Host'])->called('Can detect when a screen session fails to start');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// TEST SETUP / TEARDOWN
//
// ------------------------------------------------------------------------
$story->addTestSetup(function () {
    // use the checkpoint to share the name of our screen session
    $checkpoint = getCheckpoint();
    $checkpoint->session = "storyplayer_test_session";
    // make sure the session isn't running on the host
    foreach (hostWithRole('host_target') as $hostId) {
        $details = fromHost($hostId)->getScreenSessionDetails($checkpoint->session);
        if ($details) {
            usingHost($hostId)->stopProcess($details->pid);
        }
    }
});
$story->addTestTeardown(function () {
    $checkpoint = getCheckpoint();
    // if we've left the session running, go and kill it off
    foreach (hostWithRole('host_target') as $hostId) {
        $details = fromHost($hostId)->getScreenSessionDetails($checkpoint->session);
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsString'])->called('Can check that a string is empty');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // this should pass
    $stringData = "hello, Storyplayer";
    assertsString($stringData)->isNotEmpty();
    // and these should fail
    try {
        $nullData = null;
        assertsString($nullData)->isNotEmpty();
    } catch (Exception $e) {
        $checkpoint->nullTestPassed = true;
    }
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'ZeroMQ'])->called('Can send and receive a single message');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// PRE-TEST PREDICTION
//
// ------------------------------------------------------------------------
$story->addTestCanRunCheck(function () {
    // do we have the ZMQ extension installed?
    expectsZmq()->requirementsAreMet();
});
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
$story->addTestSetup(function () {
    // let's decide on the message we're sending and expecting back
    $checkpoint = getCheckpoint();
    $checkpoint->expectedMessage = "hello, Storyplayer";
    $checkpoint->actualMessage = null;
});
// ========================================================================
//
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsObject'])->called('Can check that data is an object');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // this should pass
    $objectData = new stdClass();
    assertsObject($objectData)->isObject();
    // and these should fail
    try {
        $nullData = null;
        assertsObject($nullData)->isObject();
    } catch (Exception $e) {
        $checkpoint->nullTestPassed = true;
    }
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsDouble'])->called('Can check that a double is greater than an integer');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // this should pass
    $actualData = 2.0;
    $expectedData1 = 1;
    assertsDouble($actualData)->isGreaterThan($expectedData1);
    // and these should fail
    try {
        $expectedData2 = 2;
        assertsDouble($actualData)->isGreaterThan($expectedData2);
    } catch (Exception $e) {
        $checkpoint->test2Passed = true;
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup('Hosts')->called('Can download a file');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
$story->addTestSetup(function () {
    // cleanup after ourselves
    foreach (hostWithRole('upload_target') as $hostname) {
        usingHost($hostname)->uploadFile(__DIR__ . '/testfile.txt', "testfile.txt");
    }
});
$story->addTestTeardown(function () {
    // cleanup after ourselves
    foreach (hostWithRole('upload_target') as $hostname) {
        // remove the file from the test environment
        usingHost($hostname)->runCommand("if [[ -e testfile.txt ]] ; then rm -f testfile.txt ; fi");
        // remove the file from our computer too
        $filename = '/tmp/testfile-' . $hostname . '.txt';
        if (file_exists($filename)) {
            // tidy up
            unlink($filename);
        }
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsDouble'])->called('Can check that a double is less than or equal to an integer');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // these should pass
    $actualData = 2.0;
    $expectedData1 = 3;
    assertsDouble($actualData)->isLessThanOrEqualTo($expectedData1);
    $actualData = 2.0;
    $expectedData2 = 2;
    assertsDouble($actualData)->isLessThanOrEqualTo($expectedData2);
    // and these should fail
    try {
        $expectedData3 = 1;
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsString'])->called('Can check that a string does not end with a given suffix');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // these should pass
    $stringData = "filename.json";
    assertsString($stringData)->doesNotEndWith("name");
    $stringData = "filename.json";
    assertsString($stringData)->doesNotEndWith(".jso");
    $stringData = "filename.json";
    assertsString($stringData)->doesNotEndWith("file");
    // and these should fail
    try {
        $stringData = "hello, Storyplayer";
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsInteger'])->called('Can check that an integer is greater than or equal to a double');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // these should pass
    $actualData = 2;
    $expectedData1 = 1.0;
    assertsInteger($actualData)->isGreaterThanOrEqualTo($expectedData1);
    $actualData = 2;
    $expectedData2 = 2.0;
    assertsInteger($actualData)->isGreaterThanOrEqualTo($expectedData2);
    // and these should fail
    try {
        $expectedData3 = 3.0;
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup('Modules')->called('AssertsArray: Can check that array contains a given key');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // this should pass
    $testData = ["alpha" => "a", "bravo" => "b", "charlie" => "c", "delta" => "d"];
    assertsArray($testData)->hasKey("alpha");
    // and this should fail
    $checkpoint->test2Exception = false;
    try {
        assertsArray($testData)->hasKey("zulu");
    } catch (Exception $e) {
        $checkpoint->test2Exception = true;
    }
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor("Storyplayer")->inGroup(["Modules", "Browser"])->called('Can open remote web page');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST PREDICTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST INSPECTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    // get the checkpoint, to store data in
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor("Storyplayer")->inGroup(["Modules", "Browser"])->called('Can retrieve a heading by ID');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST PREDICTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST INSPECTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    // get the checkpoint, to store data in
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsInteger'])->called('Can check that two integers are equal');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // this should pass
    $expectedData1 = 1;
    $actualData1 = 1;
    assertsInteger($actualData1)->equals($expectedData1);
    // and these should fail
    try {
        $expectedData2 = 2;
        assertsInteger($actualData1)->equals($expectedData2);
    } catch (Exception $e) {
        $checkpoint->test2Passed = true;
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor("Storyplayer")->inGroup(["Modules", "Browser"])->called('Can open web browser');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST PREDICTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST INSPECTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    // get the checkpoint, to store data in
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsBoolean'])->called('Can check that a boolean is not null');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    $checkpoint->test3Passed = false;
    // this should pass
    $testData1 = true;
    assertsBoolean($testData1)->isNotNull();
    $testData2 = false;
    assertsBoolean($testData2)->isNotNull();
    // these should all fail
    $testData3 = null;
    try {
        assertsBoolean($testData3)->isNotNull();
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor("Storyplayer")->inGroup(["Modules", "Browser"])->called('Can switch between browser windows');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST PREDICTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST INSPECTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    // get the checkpoint, to store data in
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup('Stories > Checkpoint')->called('Each story starts with empty checkpoint (pt 1)');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// TEST SETUP / TEARDOWN
//
// ------------------------------------------------------------------------
$story->addTestSetup(function () {
    // do nothing
});
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    $checkpoint->thisDataShouldDisappearInPt2 = true;
});
// ========================================================================
//
// POST-TEST INSPECTION
//
// ------------------------------------------------------------------------
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsObject'])->called('Can check that an object has an attribute with a given value');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // we'll use this in our comparisons
    $actualData = new stdClass();
    $actualData->attribute1 = null;
    $actualData->attribute2 = [];
    $actualData->attribute3 = true;
    $actualData->attribute4 = false;
    $actualData->attribute5 = 0.0;
    $actualData->attribute6 = 3.1415927;
    $actualData->attribute7 = 0;
    $actualData->attribute8 = 99;
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup('Modules')->called('AssertsArray: Can check that two complex arrays are equal');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // this should pass
    $testData1 = ["alpha" => "a", "bravo" => "b", "charlie" => "c", "delta" => "d", "echo" => [1, 2, 3, 4, 5]];
    $testData2 = ["alpha" => "a", "bravo" => "b", "charlie" => "c", "delta" => "d", "echo" => [1, 2, 3, 4, 5]];
    assertsArray($testData1)->equals($testData2);
    // and this should fail
    $testData3 = [1];
    $checkpoint->test2Exception = false;
    try {
        assertsArray($testData3)->equals($testData1);
    } catch (Exception $e) {
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsObject'])->called('Can check that an object is an instance of a given class');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () use($story) {
    $checkpoint = getCheckpoint();
    // these should pass
    assertsObject($story)->isInstanceOf('DataSift\\Storyplayer\\PlayerLib\\Story');
    assertsObject($checkpoint)->isInstanceOf('DataSift\\Storyplayer\\PlayerLib\\Story_Checkpoint');
    // and this should fail
    try {
        assertsObject($story)->isInstanceOf('Prose\\Prose');
    } catch (Exception $e) {
        $checkpoint->test1Passed = true;
    }
});
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsObject'])->called('Can check that two simple objects are the same');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // we'll use this in our comparisons
    $actualData = new stdClass();
    $actualData->attribute1 = "hello";
    $actualData->attribute2 = "world";
    // this should pass
    $expectedData1 = $actualData;
    assertsObject($actualData)->isSameAs($expectedData1);
    // and these should fail
    try {
        $expectedData2 = new stdClass();
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup('Config')->called('Can get system-under-test storySettings');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    // nothing to do
});
// ========================================================================
//
// POST-TEST INSPECTION
//
// ------------------------------------------------------------------------
$story->addPostTestInspection(function () {
    $storySettings = fromSystemUnderTest()->getStorySetting('testData');
    assertsObject($storySettings)->isNotNull();
    assertsObject($storySettings)->hasAttribute('name');
    assertsObject($storySettings)->hasAttribute('version');
    assertsObject($storySettings)->hasAttribute('isStorySettings');
});
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsInteger'])->called('Can check that an integer is null');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // this should pass
    $nullData = null;
    assertsInteger($nullData)->isNull();
    // and these should fail
    try {
        $doubleData = 1.1;
        assertsInteger($doubleData)->isNull();
    } catch (Exception $e) {
        $checkpoint->doubleTestPassed = true;
    }
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsDouble'])->called('Can check that two doubles are equal');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // this should pass
    $expectedData1 = 1.1;
    $actualData1 = 1.1;
    assertsDouble($actualData1)->equals($expectedData1);
    // and these should fail
    try {
        $expectedData2 = 1.12;
        assertsDouble($actualData1)->equals($expectedData2);
    } catch (Exception $e) {
        $checkpoint->test2Passed = true;
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'Host'])->called('Can stop all screen sessions');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// TEST SETUP / TEARDOWN
//
// ------------------------------------------------------------------------
$story->addTestSetup(function () {
    // use the checkpoint to share the name of our screen session
    $checkpoint = getCheckpoint();
    $checkpoint->sessions = ["storyplayer_test_session_1", "storyplayer_test_session_2", "storyplayer_test_session_3", "storyplayer_test_session_4", "storyplayer_test_session_5"];
    // make sure the session is running on each host
    foreach (hostWithRole('host_target') as $hostId) {
        foreach ($checkpoint->sessions as $session) {
            $details = fromHost($hostId)->getScreenSessionDetails($session);
            if (!$details) {
                usingHost($hostId)->startInScreen($session, 'top');
            }
        }
    }
});
$story->addTestTeardown(function () {
    $checkpoint = getCheckpoint();
    // if we've left the session running, go and kill it off
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup('Modules')->called('HTTP: Can connect to self-signed SSL server');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    foreach (hostWithRole('ssl_target') as $hostname) {
        $url = "https://" . fromHost($hostname)->getHostname();
        fromHttp()->get($url);
    }
});
// ========================================================================
//
// POST-TEST INSPECTION
//
// ------------------------------------------------------------------------
$story->addPostTestInspection(function ($st) {
    // do nothing
});
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup(['Modules', 'AssertsDouble'])->called('Can check that data is a double');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // this should pass
    $doubleData = 1.1;
    assertsDouble($doubleData)->isDouble();
    // and these should fail
    try {
        $nullData = null;
        assertsDouble($nullData)->isDouble();
    } catch (Exception $e) {
        $checkpoint->nullTestPassed = true;
    }
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor('Storyplayer')->inGroup('Modules')->called('AssertsArray: Can check that data is not null');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // this should pass
    $testData1 = ["alpha" => "a", "bravo" => "b", "charlie" => "c", "delta" => "d", "echo" => [1, 2, 3, 4, 5]];
    assertsArray($testData1)->isNotNull();
    // and this should fail
    $testData2 = null;
    $checkpoint->test2Exception = false;
    try {
        assertsArray($testData2)->isNotNull();
    } catch (Exception $e) {
        $checkpoint->test2Exception = true;
Example #29
0
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor("Storyteller")->inGroup("unit-tests")->called("Basic story");
// ========================================================================
//
// TEST ENVIRONMENT SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST PREDICTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST INSPECTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
<?php

// ========================================================================
//
// STORY DETAILS
//
// ------------------------------------------------------------------------
$story = newStoryFor("Storyplayer")->inGroup(["Modules", "Browser"])->called('Can see inside iFrames');
$story->requiresStoryplayerVersion(2);
// ========================================================================
//
// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST PREDICTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// PRE-TEST INSPECTION
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    // get the checkpoint, to store data in