public function getDataFor($metric, $startTime, $endTime) { // when are we looking for? $humanStartTime = date('Y-m-d H:i:s', $startTime); $humanEndTime = date('Y-m-d H:i:s', $endTime); // what are we doing? $log = usingLog()->startAction("get raw data from graphite for '{$metric}' between '{$humanStartTime}' and '{$humanEndTime}'"); // find out where graphite is $graphiteUrl = fromConfig()->getModuleSetting('graphite.url'); if (substr($graphiteUrl, -1, 1) !== '/') { $graphiteUrl .= '/'; } // get the requested data $response = fromHttp()->get("{$graphiteUrl}render?format=json&target={$metric}&from={$startTime}&until={$endTime}"); // are there any stats in the response? assertsArray($response->chunks)->isExpectedType(); assertsArray($response->chunks)->isNotEmpty(); // assemble the raw chunks into one string to decode $rawStats = implode("", $response->chunks); assertsString($rawStats)->isValidJson(); $stats = json_decode($rawStats); // all done $log->endAction(); return $stats; }
public function hasBody($expectedBody) { // shorthand $response = $this->args[0]; // what are we doing? $log = usingLog()->startAction(["make sure HTTP response has body", $expectedBody]); // do the comparison assertsString($response->getBody())->equals($expectedBody); // if we get here, all is well $log->endAction(); }
} try { $intData = 1; assertsString($intData)->isNotEmpty(); } catch (Exception $e) { $checkpoint->intTest2Passed = true; } try { $objectData = $checkpoint; assertsString($objectData)->isNotEmpty(); } catch (Exception $e) { $checkpoint->objectTestPassed = true; } try { $stringData = ""; assertsString($stringData)->isNotEmpty(); } catch (Exception $e) { $checkpoint->stringTestPassed = true; } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); assertsObject($checkpoint)->hasAttribute("nullTestPassed"); assertsBoolean($checkpoint->nullTestPassed)->isTrue(); assertsObject($checkpoint)->hasAttribute("arrayTestPassed"); assertsBoolean($checkpoint->arrayTestPassed)->isTrue();
$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"; assertsString($stringData)->doesNotEndWith("player"); } catch (Exception $e) { $checkpoint->test1Passed = true; } try { $stringData = "filename.json"; assertsString($stringData)->doesNotEndWith(".json"); } catch (Exception $e) { $checkpoint->test2Passed = true; } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); for ($i = 1; $i <= 2; $i++) { $attribute = "test{$i}Passed"; assertsObject($checkpoint)->hasAttributeWithValue($attribute, true); }
$checkpoint = getCheckpoint(); // these should pass $arrayData = json_encode([]); assertsString($arrayData)->isValidJson(); $objectData = json_encode($checkpoint); assertsString($objectData)->isValidJson(); // and these should fail try { $invalidData = "{ 100"; assertsString($invalidData)->isValidJson(); } catch (Exception $e) { $checkpoint->test1Passed = true; } try { $invalidData = "[ abcdef01234"; assertsString($invalidData)->isValidJson(); } catch (Exception $e) { $checkpoint->test2Passed = true; } // PHP 5.6 on Ubuntu accepts 'True' and 'False' as // valid JSON, which is a bug :( /* try { $invalidData = "[ True ]"; assertsString($invalidData)->isValidJson(); } catch (Exception $e) { $checkpoint->test3Passed = true; } try {
// // PRE-TEST INSPECTION // // ------------------------------------------------------------------------ // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // get the checkpoint, to store data in $checkpoint = getCheckpoint(); // load our test page usingBrowser()->gotoPage("http://news.bbc.co.uk"); // get the title of the test page $checkpoint->title = fromBrowser()->getTitle(); }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { // get the checkpoint $checkpoint = getCheckpoint(); // what title are we expecting? $expectedTitle = fromStoryplayer()->getStorySetting("modules.http.remotePage.title"); // do we have the title we expected? assertsObject($checkpoint)->hasAttribute('title'); assertsString($checkpoint->title)->equals($expectedTitle); });
// do we have the UUID extension installed? expectsUuid()->requirementsAreMet(); }); // ======================================================================== // // PRE-TEST INSPECTION // // ------------------------------------------------------------------------ // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // get the checkpoint, to store data in $checkpoint = getCheckpoint(); // create a UUID $checkpoint->uuid = fromUuid()->generateUuid(); }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { // get the checkpoint $checkpoint = getCheckpoint(); // do we have the content we expected? assertsObject($checkpoint)->hasAttribute('uuid'); assertsString($checkpoint->uuid)->isUuid(); });
// ------------------------------------------------------------------------ // ======================================================================== // // PRE-TEST INSPECTION // // ------------------------------------------------------------------------ // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // get the checkpoint, to store data in $checkpoint = getCheckpoint(); // load our test page usingBrowser()->gotoPage("file://" . __DIR__ . '/../../testpages/index.html'); // get the title of the test page $checkpoint->title = fromBrowser()->getTitle(); }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { // get the checkpoint $checkpoint = getCheckpoint(); // do we have the title we expected? assertsObject($checkpoint)->hasAttribute('title'); assertsString($checkpoint->title)->equals("Storyplayer: Welcome To The Tests!"); });
// ======================================================================== // // STORY DETAILS // // ------------------------------------------------------------------------ $story = newStoryFor('Storyplayer')->inGroup('Modules')->called('Users: Has loaded test users file'); $story->requiresStoryplayerVersion(2); // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // no op }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function ($st) { $test1 = fromUsers()->getUser("test1"); $test2 = fromUsers()->getUser("test2"); assertsObject($test1)->isObject(); assertsObject($test1)->hasAttribute("username"); assertsString($test1->username)->equals("test 1"); assertsObject($test2)->isObject(); assertsObject($test2)->hasAttribute("username"); assertsString($test2->username)->equals("test 2"); });
} try { $intData = 0; assertsString($intData)->isNotNull(); } catch (Exception $e) { $checkpoint->intTest1Passed = true; } try { $intData = 1; assertsString($intData)->isNotNull(); } catch (Exception $e) { $checkpoint->intTest2Passed = true; } try { $objectData = $checkpoint; assertsString($objectData)->isNotNull(); } catch (Exception $e) { $checkpoint->objectTestPassed = true; } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); assertsObject($checkpoint)->hasAttribute("nullTestPassed"); assertsBoolean($checkpoint->nullTestPassed)->isTrue(); assertsObject($checkpoint)->hasAttribute("arrayTestPassed"); assertsBoolean($checkpoint->arrayTestPassed)->isTrue();
<?php // ======================================================================== // // STORY DETAILS // // ------------------------------------------------------------------------ $story = newStoryFor('Storyplayer')->inGroup('Stories > Groups')->generateName(); $story->requiresStoryplayerVersion(2); // ======================================================================== // // STORY SETUP / TEAR-DOWN // // ------------------------------------------------------------------------ // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // nothing to do }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () use($story) { $filename = $story->getName(); assertsString($filename)->equals('CanGenerateNameStory.php'); });
// and these should fail try { $stringData = "filename.json"; assertsString($stringData)->startsWith("name"); } catch (Exception $e) { $checkpoint->test1Passed = true; } try { $stringData = "filename.json"; assertsString($stringData)->startsWith(".json"); } catch (Exception $e) { $checkpoint->test2Passed = true; } try { $stringData = "filename.json"; assertsString($stringData)->startsWith("ile"); } catch (Exception $e) { $checkpoint->test3Passed = true; } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); for ($i = 1; $i <= 3; $i++) { $attribute = "test{$i}Passed"; assertsObject($checkpoint)->hasAttributeWithValue($attribute, true); }
// ------------------------------------------------------------------------ // ======================================================================== // // PRE-TEST INSPECTION // // ------------------------------------------------------------------------ // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // get the checkpoint, to store data in $checkpoint = getCheckpoint(); // load our test page usingBrowser()->gotoPage("file://" . __DIR__ . '/../../testpages/WorkingWithForms.html'); // get a field from a form $checkpoint->field1 = fromForm("test_form")->getValue()->fieldLabelled('Page Name'); }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { // get the checkpoint $checkpoint = getCheckpoint(); // do we have the title we expected? assertsObject($checkpoint)->hasAttribute('field1'); assertsString($checkpoint->field1)->equals("Storyplayer: Working With Forms"); });
$checkpoint->expectedData = "new test data"; }); $story->addTestTeardown(function () { $test1 = fromUsers()->getUser("test1"); if (isset($test1->extraData)) { unset($test1->extraData); } }); // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { $checkpoint = getCheckpoint(); $test1 = fromUsers()->getUser("test1"); assertsObject($test1)->doesNotHaveAttribute("extraData"); $test1->extraData = $checkpoint->expectedData; }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function ($st) { $checkpoint = getCheckpoint(); $test1 = fromUsers()->getUser("test1"); assertsObject($test1)->isObject(); assertsObject($test1)->hasAttribute("extraData"); assertsString($test1->extraData)->equals($checkpoint->expectedData); });
$stringData = "filename.json"; assertsString($stringData)->doesNotStartWith("name"); $stringData = "filename.json"; assertsString($stringData)->doesNotStartWith(".json"); $stringData = "filename.json"; assertsString($stringData)->doesNotStartWith("ile"); // and these should fail try { $stringData = "hello, Storyplayer"; assertsString($stringData)->doesNotStartWith("hello"); } catch (Exception $e) { $checkpoint->test1Passed = true; } try { $stringData = "filename.json"; assertsString($stringData)->doesNotStartWith("file"); } catch (Exception $e) { $checkpoint->test2Passed = true; } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); for ($i = 1; $i <= 2; $i++) { $attribute = "test{$i}Passed"; assertsObject($checkpoint)->hasAttributeWithValue($attribute, true); }
// ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // get the checkpoint, to store data in $checkpoint = getCheckpoint(); // load our test page usingBrowser()->gotoPage("file://" . __DIR__ . '/../../testpages/WorkingWithIFrames.html'); // get a h1 $checkpoint->mainHeader = fromBrowser()->getText()->fromHeadingWithId('storyplayer_working_with_iframes'); // switch to the iFrame usingBrowser()->switchToIframe('iframe1'); // get the h1 now $checkpoint->iFrameHeader = fromBrowser()->getText()->fromHeadingWithId('storyplayer_working_with_iframes'); }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { // get the checkpoint $checkpoint = getCheckpoint(); // do we have the content we expected? assertsObject($checkpoint)->hasAttribute('mainHeader'); assertsString($checkpoint->mainHeader)->equals("Storyplayer: Working With IFrames"); assertsObject($checkpoint)->hasAttribute('iFrameHeader'); assertsString($checkpoint->iFrameHeader)->equals("IFrame Content"); });
// ------------------------------------------------------------------------ $story->addAction(function () { $checkpoint = getCheckpoint(); // these should pass $uuidData = "de305d54-75b4-431b-adb2-eb6b9e546013"; assertsString($uuidData)->isUuid(); // and these should fail try { $invalidData = "de305d54-75b4-431b-adb2-eb6b9e54601g"; assertsString($invalidData)->isUuid(); } catch (Exception $e) { $checkpoint->test1Passed = true; } try { $invalidData = "de305d-5475b4-431b-adb2-eb6b9e546013"; assertsString($invalidData)->isUuid(); } catch (Exception $e) { $checkpoint->test2Passed = true; } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); for ($i = 1; $i <= 2; $i++) { $attribute = "test{$i}Passed"; assertsObject($checkpoint)->hasAttributeWithValue($attribute, true); }
// ------------------------------------------------------------------------ // ======================================================================== // // PRE-TEST INSPECTION // // ------------------------------------------------------------------------ // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // get the checkpoint, to store data in $checkpoint = getCheckpoint(); // load our test page usingBrowser()->gotoPage("file://" . __DIR__ . '/../../testpages/index.html'); // get a h2 by its ID $checkpoint->content = fromBrowser()->getText()->fromHeadingWithId('self_test_website'); }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { // get the checkpoint $checkpoint = getCheckpoint(); // do we have the content we expected? assertsObject($checkpoint)->hasAttribute('content'); assertsString($checkpoint->content)->equals("Self-Test Website"); });
// PRE-TEST PREDICTION // // ------------------------------------------------------------------------ // ======================================================================== // // PRE-TEST INSPECTION // // ------------------------------------------------------------------------ // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // load our test page usingBrowser()->gotoPage("file://" . __DIR__ . '/../../testpages/index.html'); }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { // if this feature is working, the browser should already be open // and we can just grab the title $title = fromBrowser()->getTitle(); // do we have the title we expected? assertsString($title)->equals("Storyplayer: Welcome To The Tests!"); // all done - shut down the browser stopDevice(); });
// and these should fail try { $stringData = "filename.json"; assertsString($stringData)->endsWith("name"); } catch (Exception $e) { $checkpoint->test1Passed = true; } try { $stringData = "filename.json"; assertsString($stringData)->endsWith(".jso"); } catch (Exception $e) { $checkpoint->test2Passed = true; } try { $stringData = "filename.json"; assertsString($stringData)->endsWith("file"); } catch (Exception $e) { $checkpoint->test3Passed = true; } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); for ($i = 1; $i <= 3; $i++) { $attribute = "test{$i}Passed"; assertsObject($checkpoint)->hasAttributeWithValue($attribute, true); }
// these should pass $stringData = "hello, Storyplayer"; $expected1Data = ["hello, Storyplayer", "and welcome", "to these tests"]; assertsString($stringData)->isIn($expected1Data); $expected2Data = ["a" => "hello, Storyplayer", "b" => "and welcome", "c" => "to these tests"]; assertsString($stringData)->isIn($expected2Data); // and these should fail try { $expected3Data = ["hello, Storyplayer!", "and welcome", "to these tests"]; assertsString($stringData)->isIn($expected3Data); } catch (Exception $e) { $checkpoint->test1Passed = true; } try { $expected4Data = ["a" => "hello, Storyplayer!", "b" => "and welcome", "c" => "to these tests"]; assertsString($stringData)->isIn($expected4Data); } catch (Exception $e) { $checkpoint->test2Passed = true; } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); for ($i = 1; $i <= 2; $i++) { $attribute = "test{$i}Passed"; assertsObject($checkpoint)->hasAttributeWithValue($attribute, true); }
$checkpoint = getCheckpoint(); // these should pass $stringData = md5("filename.json"); assertsString($stringData)->isHash(32); // and these should fail try { $stringData = "hello, Storyplayer"; assertsString($stringData)->isHash(); } catch (Exception $e) { $checkpoint->test1Passed = true; } try { // valid hex characters, but an odd length // hashes are an even number of characters long $stringData = "abcdef01234"; assertsString($stringData)->isHash(); } catch (Exception $e) { $checkpoint->test2Passed = true; } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); for ($i = 1; $i <= 2; $i++) { $attribute = "test{$i}Passed"; assertsObject($checkpoint)->hasAttributeWithValue($attribute, true); }
} try { $intData = 0; assertsString($intData)->isString(); } catch (Exception $e) { $checkpoint->intTest1Passed = true; } try { $intData = 1; assertsString($intData)->isString(); } catch (Exception $e) { $checkpoint->intTest2Passed = true; } try { $objectData = $checkpoint; assertsString($objectData)->isString(); } catch (Exception $e) { $checkpoint->objectTestPassed = true; } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); assertsObject($checkpoint)->hasAttribute("nullTestPassed"); assertsBoolean($checkpoint->nullTestPassed)->isTrue(); assertsObject($checkpoint)->hasAttribute("arrayTestPassed"); assertsBoolean($checkpoint->arrayTestPassed)->isTrue();
$checkpoint = getCheckpoint(); // load our test page usingBrowser()->gotoPage("file://" . __DIR__ . '/../../testpages/WorkingWithWindows.html'); // get the h1 $checkpoint->mainHeader = fromBrowser()->getText()->fromHeadingWithId('storyplayer_working_with_windows'); // open the second window usingBrowser()->click()->linkWithText('open a second window'); // switch to the second window usingBrowser()->switchToWindow("Storyplayer: Second Window"); // get the h1 $checkpoint->secondHeader = fromBrowser()->getText()->fromHeadingWithId('storyplayer_second_window'); // close the second window // this leaves the browser in a bit of a state usingBrowser()->closeCurrentWindow(); // switch back to the first window usingBrowser()->switchToWindow("Storyplayer: Working With Windows"); }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { // get the checkpoint $checkpoint = getCheckpoint(); // do we have the content we expected? assertsObject($checkpoint)->hasAttribute('mainHeader'); assertsString($checkpoint->mainHeader)->equals("Storyplayer: Working With Windows"); assertsObject($checkpoint)->hasAttribute('secondHeader'); assertsString($checkpoint->secondHeader)->equals("Storyplayer: Second Window"); });
// // TEST SETUP / TEARDOWN // // ------------------------------------------------------------------------ $story->addTestSetup(function () { // this is what we expect to retrieve from the test environment config $checkpoint = getCheckpoint(); $checkpoint->expected = "successfully retrieved this appSetting :)"; }); // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // do nothing }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function ($st) { // what value do we expect to retrieve? $expected = fromCheckpoint()->get('expected'); // make sure we have it foreach (hostWithRole('host_target') as $hostId) { $actual = fromHost($hostId)->getAppSetting('host.expected'); assertsString($actual)->equals($expected); } });
} try { $objectData = $checkpoint; assertsString($objectData)->isNull(); } catch (Exception $e) { $checkpoint->objectTestPassed = true; } try { $stringData = ""; assertsString($stringData)->isNull(); } catch (Exception $e) { $checkpoint->stringTest1Passed = true; } try { $stringData = "hello, Storyplayer"; assertsString($stringData)->isNull(); } catch (Exception $e) { $checkpoint->stringTest2Passed = true; } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); assertsObject($checkpoint)->hasAttribute("arrayTestPassed"); assertsBoolean($checkpoint->arrayTestPassed)->isTrue(); assertsObject($checkpoint)->hasAttribute("booleanTest1Passed"); assertsBoolean($checkpoint->booleanTest1Passed)->isTrue();
<?php // ======================================================================== // // STORY DETAILS // // ------------------------------------------------------------------------ $story = newStoryFor('Storyplayer')->inGroup('Config')->called('Can get system-under-test name'); $story->requiresStoryplayerVersion(2); // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // nothing to do }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $sutName = fromSystemUnderTest()->getName(); assertsString($sutName)->isNotEmpty(); });
// // ------------------------------------------------------------------------ // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // we're going to store the received message in here $checkpoint = getCheckpoint(); foreach (firstHostWithRole("zmq_target") as $hostId) { $context = usingZmqContext()->getZmqContext(); $inPort = fromHost($hostId)->getStorySetting("zmq.single.inPort"); $outPort = fromHost($hostId)->getStorySetting("zmq.single.outPort"); $inSocket = usingZmqContext($context)->connectToHost($hostId, $inPort, 'PUSH'); $outSocket = usingZmqContext($context)->connectToHost($hostId, $outPort, 'PULL'); usingZmqSocket($inSocket)->send($checkpoint->expectedMessage); $checkpoint->actualMessage = fromZmqSocket($outSocket)->recv(); } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); assertsObject($checkpoint)->hasAttribute("expectedMessage"); assertsObject($checkpoint)->hasAttribute("actualMessage"); assertsString($checkpoint->actualMessage)->equals($checkpoint->expectedMessage); });
// POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { foreach (hostWithRole('upload_target') as $hostId) { // get the default user details for this test environment $hostUser = fromHost($hostId)->getStorySetting("user.username"); $hostGroup = fromHost($hostId)->getStorySetting("user.group"); // get the details for this file $details = fromHost($hostId)->getFileDetails('testfile.txt'); // make sure we have the details that we expect assertsObject($details)->isNotNull(); assertsObject($details)->hasAttribute("user"); assertsString($details->user)->equals($hostUser); assertsObject($details)->hasAttribute("group"); assertsString($details->group)->equals($hostGroup); } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { foreach (hostWithRole('upload_target') as $hostId) { // get the default user details for this test environment $hostUser = fromHost($hostId)->getStorySetting("user.username"); $hostGroup = fromHost($hostId)->getStorySetting("user.group"); // check the details for this file expectsHost($hostId)->hasFileWithPermissions('testfile.txt', $hostUser, $hostGroup, 0644); }