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


PHP LimeTest::stub方法代码示例

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


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

示例1: LimeTest

<?php

/*
 * This file is part of the Lime framework.
 *
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 * (c) Bernhard Schussek <bernhard.schussek@symfony-project.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */
LimeAnnotationSupport::enable();
$t = new LimeTest();
// @BeforeAll
$file1 = $t->stub('LimeFile');
$file1->getPath()->returns('test1.txt');
$file1->replay();
$file2 = $t->stub('LimeFile');
$file2->getPath()->returns('test2.txt');
$file2->replay();
$file3 = $t->stub('LimeFile');
$file3->getPath()->returns('test3.txt');
$file3->replay();
// @Before
$label1 = new LimeLabel();
$label1->addFile($file1);
$label1->addFile($file2);
$label2 = new LimeLabel();
$label2->addFile($file1);
$label2->addFile($file3);
// @Test: intersect() returns the intersection of two labels
开发者ID:b00giZm,项目名称:lime,代码行数:31,代码来源:LimeLabelTest.php

示例2: testDoSomething

    {
        $this->impl->tearDown();
    }
    public function testDoSomething()
    {
        $this->impl->testDoSomething();
    }
    public function testDoSomethingElse()
    {
        $this->impl->testDoSomethingElse();
    }
}
$t = new LimeTest();
// @Before
$output = $t->mock('LimeOutputInterface', array('nice' => true));
$configuration = $t->stub('LimeConfiguration');
$configuration->getTestOutput()->returns($output);
$configuration->replay();
$test = new TestCase($configuration);
$output->reset();
$test->impl = $t->mock('Test');
// @Test: The methods setUp() and tearDown() are called before and after each test method
// fixtures
$test->impl->setUp();
$test->impl->testDoSomething();
$test->impl->tearDown();
$test->impl->setUp();
$test->impl->testDoSomethingElse();
$test->impl->tearDown();
$test->impl->replay();
// test
开发者ID:b00giZm,项目名称:lime,代码行数:31,代码来源:LimeTestCaseTest.php

示例3: LimeTest

<?php

/*
 * This file is part of the Lime framework.
 *
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 * (c) Bernhard Schussek <bernhard.schussek@symfony-project.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */
LimeAnnotationSupport::enable();
$t = new LimeTest();
// @Before
$colorizer = $t->stub('LimeColorizer');
$printer = new LimePrinter($colorizer);
// @After
$colorizer = null;
$printer = null;
// @Test: printText() prints text using the given style
// fixtures
$colorizer->colorize('My text', 'RED')->returns('<RED>My text</RED>');
$colorizer->replay();
// test
ob_start();
$printer->printText('My text', 'RED');
$result = ob_get_clean();
// assertions
$t->is($result, '<RED>My text</RED>', 'The result was colorized and printed');
// @Test: printLine() prints text followed by a newline
// fixtures
开发者ID:b00giZm,项目名称:lime,代码行数:31,代码来源:LimePrinterTest.php

示例4: MyParserDriver

$cp = new Sonata_Parser_Config(new MyParserDriver());
// @After
unlink($configFile);
unset($cp);
// @Test: ->getDriver()
$t->is($cp->getDriver() instanceof MyParserDriver, true, 'The driver was returned correctly');
// @Test: ->setDriver()
$cp->setDriver(new MyOtherParserDriver());
$t->is($cp->getDriver() instanceof MyOtherParserDriver, true, 'The new driver was set correctly');
// @Test: ->parse()
try {
    $cp->parse('some_non_existing_file.yml');
    $t->fail('No code should be executed after this');
} catch (RuntimeException $ex) {
    $t->pass('An exception is thrown if the config file cannot be found');
}
$driverStub = $t->stub('MyParserDriver');
$driverStub->doParse($configFile)->throws('InvalidArgumentException');
$driverStub->replay();
$cp->setDriver($driverStub);
try {
    $cp->parse($configFile);
    $t->fail('No code should be executed after this');
} catch (InvalidArgumentException $ex) {
    $t->pass('An exception thrown by the driver will also be thrown by the config parser');
}
$driverStub = $t->stub('MyParserDriver');
$driverStub->doParse($configFile)->returns(array("foo" => array("bar" => 42, "baz" => 4711)));
$driverStub->replay();
$cp->setDriver($driverStub);
$t->is($cp->parse($configFile), array("foo" => array("bar" => 42, "baz" => 4711)), 'Returns an array with all parsed values');
开发者ID:b00giZm,项目名称:sonata-framework,代码行数:31,代码来源:Sonata_Parser_ConfigTest.php

示例5: dirname

<?php

/**
 * This file is part of the Sonata RESTful PHP framework
 * (c) 2009-2010 Pascal Cremer <b00giZm@gmail.com>
 *
 * @author Pascal Cremer <b00giZm@gmail.com>
 */
require_once dirname(__FILE__) . '/bootstrap.php';
$t = new LimeTest();
// @Before
$requestStub = $t->stub('Sonata_Request');
$rm = new Sonata_RouteMap($requestStub);
// @After
unset($requestMock);
unset($rm);
// @Test: ->connect()
// @Test: trying '/foo/bar'
$rm->connect('/foo/bar', 'foo', array(), 'bar');
$routes = $rm->getRoutes();
$t->is(count($routes), 1, 'The route was connected (added) to the routes array');
$route = array_pop($routes);
$t->ok($route instanceof Sonata_Route, 'The added route is a PSRoute object');
$t->is($route->getPattern(), '/^\\/foo\\/bar/', 'The pattern has the right form further regex operations');
$t->is($route->getResource(), 'foo', 'The resource was set correctly');
$t->is($route->getVerbs(), array(), 'There were no verbs to set');
$t->is($route->getAction(), 'bar', 'The action was set correctly');
$t->is($route->getParameters(), array(), 'There were no parameters to set');
$t->is($route->getCommandName(), 'BarFoo', 'The camelized command name is generated correctly');
// @Test: trying '/my_foo/my_bar'
$rm->connect('/my_foo/my_bar', 'my_foo', array(), 'my_bar');
开发者ID:b00giZm,项目名称:sonata-framework,代码行数:31,代码来源:Sonata_RouteMapAndRouteTest.php

示例6: LimeTest

<?php

/*
 * This file is part of the Lime framework.
 *
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 * (c) Bernhard Schussek <bernhard.schussek@symfony-project.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */
LimeAnnotationSupport::enable();
$t = new LimeTest();
// @Before
$printer = $t->mock('LimePrinter', array('strict' => true));
$configuration = $t->stub('LimeConfiguration');
$configuration->getVerbose()->returns(false);
$configuration->getProcesses()->returns(1);
$configuration->replay();
$output = new LimeOutputSuite($printer, $configuration);
// @After
$printer = null;
$output = null;
// @Test: When close() is called, the test summary is printed
// fixtures
$printer->printText(str_pad('script', 73, '.'));
$printer->printLine("ok", LimePrinter::OK);
$printer->replay();
// test
$output->focus('/test/script');
$output->pass('A passed test', 'Class', 100, '/test/script', 11);
开发者ID:b00giZm,项目名称:lime,代码行数:31,代码来源:LimeOutputSuiteTest.php


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