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


PHP LimeTest::same方法代码示例

本文整理汇总了PHP中LimeTest::same方法的典型用法代码示例。如果您正苦于以下问题:PHP LimeTest::same方法的具体用法?PHP LimeTest::same怎么用?PHP LimeTest::same使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LimeTest的用法示例。


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

示例1: array

// test
$m->testMethod(1, 'foobar')->callback(array('TestCallbackClass', 'callback'));
$m->replay();
$value = $m->testMethod(1, 'foobar');
// assertions
$t->is(TestCallbackClass::$arguments, array(1, 'foobar'), 'The arguments have been passed to the callback');
$t->is($value, 'elvis is alive', 'The return value of the callback has been passed through');
// @Test: If a callback AND a return value is configured, the return value of the callback is ignored
// test
$m->testMethod()->callback(array('TestCallbackClass', 'callback'))->returns('elvis sure is dead');
$m->replay();
$value = $m->testMethod();
// assertions
$t->is($value, 'elvis sure is dead', 'The return value of the callback was ignored');
// @Test: The return value of the callback is ignored even if the configured return value is NULL
// test
$m->testMethod()->callback(array('TestCallbackClass', 'callback'))->returns(null);
$m->replay();
$value = $m->testMethod();
// assertions
$t->same($value, null, 'The return value of the callback was ignored');
// @Test: Parameters are passed to the callback correctly, if any parameters are expected
// fixtures
TestCallbackClass::$arguments = null;
// test
$m->method('testMethod')->callback(array('TestCallbackClass', 'callback'));
$m->replay();
$value = $m->testMethod(1, 'foobar');
// assertions
$t->is(TestCallbackClass::$arguments, array(1, 'foobar'), 'The arguments have been passed to the callback');
$t->is($value, 'elvis is alive', 'The return value of the callback has been passed through');
开发者ID:b00giZm,项目名称:lime,代码行数:31,代码来源:LimeMockTest.php

示例2: array

$t->is($paramHolder->getAll(), $params, 'All parameters were added correctly');
$paramHolder->add(null);
$t->isnt($paramHolder->getAll(), null, 'Nothing is added if NULL was given');
$paramHolder->add(array());
$t->isntSame($paramHolder->getAll(), array(), 'Nothing is added if an empty array was given');
$paramHolder->add('this fails');
$t->isnt($paramHolder->getAll(), 'this fails', 'Nothing is added if parameter isn\'t an array');
// @Test: ->get()
$foo = $paramHolder->get('foo');
$t->is($foo, 42, 'The value is retrieved correctly');
$rex = $paramHolder->get('rex');
$t->is($rex, null, 'NULL is returned if the parameter could not be found');
$rex = $paramHolder->get('rex', 'fido');
$t->is($rex, 'fido', 'If a default value is given for a non-existing parameter, the default value is returned');
// @Test: ->getNames()
$t->same($paramHolder->getNames(), array('foo', 'bar', 'baz'), 'All parameter names are retrieved correctly');
// @Test: ->has()
$t->is($paramHolder->has('foo'), true, 'TRUE is returned if the parameter exists');
$t->is($paramHolder->has('rex'), false, 'FALSE is returned if the parameter does not exist');
// @Test: ->remove()
$ret = $paramHolder->remove('bar');
$t->is($paramHolder->has('bar'), false, 'The parameter was removed correctly');
$t->is($ret, 4711, 'When removing a paramter, its value is returned correctly');
$ret = $paramHolder->remove('rex');
$t->is($ret, null, 'NULL is returned for non-existing parameters');
$ret = $paramHolder->remove('rex', 'fido');
$t->is($ret, 'fido', 'If a default value is given for a non-existing parameter, the default value is returned');
// @Test: ->set()
$paramHolder->set('rex', 'fido');
$t->is($paramHolder->get('rex'), 'fido', 'New parameters are set correctly');
// @Test: ->setByRef()
开发者ID:b00giZm,项目名称:sonata-framework,代码行数:31,代码来源:Sonata_ParameterHolderTest.php

示例3: SafeDecorator

$t->is($safe->doSomething(), 'ok', '->__call() invokes the embedded method');
// ->__isset() ->__unset()
$t->diag('->__isset() ->__unset()');
class TestClass3
{
    public $boolValue = true, $nullValue = null;
}
$safe = new SafeDecorator(new TestClass3());
$t->is(isset($safe->boolValue), true, '->__isset() returns true if the property is not null');
$t->is(isset($safe->nullValue), false, '->__isset() returns false if the property is null');
$t->is(isset($safe->undefinedValue), false, '->__isset() returns false if the property does not exist');
unset($safe->boolValue);
$t->is(isset($safe->boolValue), false, '->__unset() unsets the embedded property');
// Iterator
$t->diag('Iterator');
$input = array('one' => 1, 'two' => 2, 'three' => 3, 'children' => array(1, 2, 3));
$output = array();
$safe = new SafeDecorator($input);
foreach ($safe as $key => $value) {
    $output[$key] = $value;
}
$t->same($output, $input, '"Iterator" implementation imitates an array');
// ArrayAccess
$t->diag('ArrayAccess');
$safe = new SafeDecorator(array('foo' => 'bar'));
$t->is($safe['foo'], 'bar', '"ArrayAccess" implementation returns a value from the embedded array');
$safe['foo'] = 'baz';
$t->is($safe['foo'], 'baz', '"ArrayAccess" implementation sets a value on the embedded array');
$t->is(isset($safe['foo']), true, '"ArrayAccess" checks if a value is set on the embedded array');
unset($safe['foo']);
$t->is(isset($safe['foo']), false, '"ArrayAccess" unsets a value on the embedded array');
开发者ID:saahilgoyal,项目名称:symfony,代码行数:31,代码来源:SafeDecoratorTest.php


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