当前位置: 首页>>代码示例>>PHP>>正文


PHP assertsBoolean函数代码示例

本文整理汇总了PHP中assertsBoolean函数的典型用法代码示例。如果您正苦于以下问题:PHP assertsBoolean函数的具体用法?PHP assertsBoolean怎么用?PHP assertsBoolean使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了assertsBoolean函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCheckpoint

//
// ------------------------------------------------------------------------
// ========================================================================
//
// 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;
    }
});
// ========================================================================
//
// POST-TEST INSPECTION
//
// ------------------------------------------------------------------------
$story->addPostTestInspection(function () {
    $checkpoint = getCheckpoint();
    assertsObject($checkpoint)->hasAttribute("test2Passed");
    assertsBoolean($checkpoint->test2Passed)->isTrue();
});
开发者ID:datasift,项目名称:storyplayer,代码行数:31,代码来源:30b-CanAssertDoubleIsGreaterThanIntegerStory.php

示例2: assertsDouble

    try {
        $stringData = "";
        assertsDouble($stringData)->isDouble();
    } 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();
    assertsObject($checkpoint)->hasAttribute("booleanTest1Passed");
    assertsBoolean($checkpoint->booleanTest1Passed)->isTrue();
    assertsObject($checkpoint)->hasAttribute("booleanTest2Passed");
    assertsBoolean($checkpoint->booleanTest2Passed)->isTrue();
    assertsObject($checkpoint)->hasAttribute("intTest1Passed");
    assertsBoolean($checkpoint->intTest1Passed)->isTrue();
    assertsObject($checkpoint)->hasAttribute("intTest2Passed");
    assertsBoolean($checkpoint->intTest2Passed)->isTrue();
    assertsObject($checkpoint)->hasAttribute("objectTestPassed");
    assertsBoolean($checkpoint->objectTestPassed)->isTrue();
    assertsObject($checkpoint)->hasAttribute("stringTestPassed");
    assertsBoolean($checkpoint->stringTestPassed)->isTrue();
});
开发者ID:datasift,项目名称:storyplayer,代码行数:31,代码来源:30a-CanAssertIsDoubleStory.php

示例3: newStoryFor

//
// ------------------------------------------------------------------------
$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
//
// ------------------------------------------------------------------------
$story->addPostTestInspection(function ($st) {
    $checkpoint = getCheckpoint();
    assertsObject($checkpoint)->hasAttribute('thisDataShouldDisappearInPt2');
    assertsBoolean($checkpoint->thisDataShouldDisappearInPt2)->isTrue();
});
开发者ID:datasift,项目名称:storyplayer,代码行数:31,代码来源:01a-EachStoryStartsWithEmptyCheckpointStory.php

示例4: getCheckpoint

// ------------------------------------------------------------------------
// ========================================================================
//
// 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) {
        $checkpoint->test2Exception = true;
    }
});
// ========================================================================
//
// POST-TEST INSPECTION
//
// ------------------------------------------------------------------------
$story->addPostTestInspection(function () {
    $checkpoint = getCheckpoint();
    assertsObject($checkpoint)->hasAttribute("test2Exception");
    assertsBoolean($checkpoint->test2Exception)->isTrue();
});
开发者ID:datasift,项目名称:storyplayer,代码行数:31,代码来源:10b-CanAssertTwoComplexArraysAreEqualStory.php

示例5: assertsObject

    assertsObject($actualData)->isNotEmpty();
    $actualData = new stdClass();
    $actualData->attribute1 = 99;
    assertsObject($actualData)->isNotEmpty();
    $actualData = new stdClass();
    $actualData->attribute1 = $checkpoint;
    assertsObject($actualData)->isNotEmpty();
    $actualData = new stdClass();
    $actualData->attribute1 = "";
    assertsObject($actualData)->isNotEmpty();
    $actualData = new stdClass();
    $actualData->attribute1 = "hello, Storyplayer";
    assertsObject($actualData)->isNotEmpty();
    // and this should fail
    $actualData = new stdClass();
    try {
        assertsObject($actualData)->isNotEmpty();
    } catch (Exception $e) {
        $checkpoint->test1Passed = true;
    }
});
// ========================================================================
//
// POST-TEST INSPECTION
//
// ------------------------------------------------------------------------
$story->addPostTestInspection(function () {
    $checkpoint = getCheckpoint();
    assertsObject($checkpoint)->hasAttribute("test1Passed");
    assertsBoolean($checkpoint->test1Passed)->equals(true);
});
开发者ID:datasift,项目名称:storyplayer,代码行数:31,代码来源:50b-CanAssertObjectIsNotEmptyStory.php

示例6: assertsObject

        $checkpoint->test108Passed = true;
    }
    try {
        assertsObject($actualData)->hasAttributeWithValue('attribute11', 99);
    } catch (Exception $e) {
        $checkpoint->test109Passed = true;
    }
    try {
        assertsObject($actualData)->hasAttributeWithValue('attribute11', $checkpoint);
    } catch (Exception $e) {
        $checkpoint->test110Passed = true;
    }
    try {
        assertsObject($actualData)->hasAttributeWithValue('attribute11', "");
    } catch (Exception $e) {
        $checkpoint->test111Passed = true;
    }
});
// ========================================================================
//
// POST-TEST INSPECTION
//
// ------------------------------------------------------------------------
$story->addPostTestInspection(function () {
    $checkpoint = getCheckpoint();
    for ($x = 1; $x <= 111; $x++) {
        $attributeName = "test{$x}Passed";
        assertsObject($checkpoint)->hasAttribute($attributeName);
        assertsBoolean($checkpoint->{$attributeName})->equals(true);
    }
});
开发者ID:datasift,项目名称:storyplayer,代码行数:31,代码来源:50b-CanAssertObjectHasAnAttributeWithAGivenValueStory.php

示例7: getCheckpoint

//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // this should pass
    $data1 = [];
    assertsArray($data1)->isArray();
    // and this should fail
    $checkpoint->data2Exception = false;
    try {
        $data2 = "";
        assertsArray($data2)->isArray();
    } catch (Exception $e) {
        $checkpoint->data2Exception = true;
    }
});
// ========================================================================
//
// POST-TEST INSPECTION
//
// ------------------------------------------------------------------------
$story->addPostTestInspection(function () {
    $checkpoint = getCheckpoint();
    assertsObject($checkpoint)->hasAttribute("data2Exception");
    assertsBoolean($checkpoint->data2Exception)->isTrue();
});
开发者ID:datasift,项目名称:storyplayer,代码行数:31,代码来源:10a-CanAssertIsArrayStory.php

示例8: assertsString

        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();
    assertsObject($checkpoint)->hasAttribute("booleanTest1Passed");
    assertsBoolean($checkpoint->booleanTest1Passed)->isTrue();
    assertsObject($checkpoint)->hasAttribute("booleanTest2Passed");
    assertsBoolean($checkpoint->booleanTest2Passed)->isTrue();
    assertsObject($checkpoint)->hasAttribute("doubleTest1Passed");
    assertsBoolean($checkpoint->doubleTest1Passed)->isTrue();
    assertsObject($checkpoint)->hasAttribute("doubleTest2Passed");
    assertsBoolean($checkpoint->doubleTest2Passed)->isTrue();
    assertsObject($checkpoint)->hasAttribute("intTest1Passed");
    assertsBoolean($checkpoint->intTest1Passed)->isTrue();
    assertsObject($checkpoint)->hasAttribute("intTest2Passed");
    assertsBoolean($checkpoint->intTest2Passed)->isTrue();
    assertsObject($checkpoint)->hasAttribute("objectTestPassed");
    assertsBoolean($checkpoint->objectTestPassed)->isTrue();
});
开发者ID:datasift,项目名称:storyplayer,代码行数:31,代码来源:60a-CanAssertIsStringStory.php

示例9: getCheckpoint

// STORY SETUP / TEAR-DOWN
//
// ------------------------------------------------------------------------
// ========================================================================
//
// POSSIBLE ACTION(S)
//
// ------------------------------------------------------------------------
$story->addAction(function () {
    $checkpoint = getCheckpoint();
    // this should pass
    $objectData = new stdClass();
    assertsObject($objectData)->isNotNull();
    // and these should fail
    try {
        $nullData = null;
        assertsObject($nullData)->isNotNull();
    } catch (Exception $e) {
        $checkpoint->nullTestPassed = true;
    }
});
// ========================================================================
//
// POST-TEST INSPECTION
//
// ------------------------------------------------------------------------
$story->addPostTestInspection(function () {
    $checkpoint = getCheckpoint();
    assertsObject($checkpoint)->hasAttribute("nullTestPassed");
    assertsBoolean($checkpoint->nullTestPassed)->isTrue();
});
开发者ID:datasift,项目名称:storyplayer,代码行数:31,代码来源:50b-CanAssertObjectIsNotNullStory.php


注:本文中的assertsBoolean函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。