本文整理汇总了PHP中newStoryFor函数的典型用法代码示例。如果您正苦于以下问题:PHP newStoryFor函数的具体用法?PHP newStoryFor怎么用?PHP newStoryFor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了newStoryFor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newStoryFor
<?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);
示例2: newStoryFor
<?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;
}
示例3: newStoryFor
<?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;
});
// ========================================================================
//
示例4: newStoryFor
<?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;
}
示例5: newStoryFor
<?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;
示例6: newStoryFor
<?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);
}
示例7: newStoryFor
<?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;
开发者ID:datasift,项目名称:storyplayer,代码行数:31,代码来源:30b-CanAssertDoubleIsLessThanOrEqualToAnIntegerStory.php
示例8: newStoryFor
<?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";
示例9: newStoryFor
<?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;
开发者ID:datasift,项目名称:storyplayer,代码行数:31,代码来源:40b-CanAssertIntegerIsGreaterThanOrEqualToADoubleStory.php
示例10: newStoryFor
<?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;
}
示例11: newStoryFor
<?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
示例12: newStoryFor
<?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;
示例13: newStoryFor
<?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();
示例14: newStoryFor
<?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
//
// ------------------------------------------------------------------------
示例15: newStoryFor
<?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;
开发者ID:datasift,项目名称:storyplayer,代码行数:31,代码来源:50b-CanAssertObjectHasAnAttributeWithAGivenValueStory.php