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


PHP LimeTest::mock方法代码示例

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


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

示例1: count

unset($fooFilter);
unset($barFilter);
unset($bazFilter);
// @Test: ->getFilters()
$fc = new Sonata_FilterChain();
$t->ok(is_array($fc->getFilters()) && count($fc->getFilters()) == 0, 'The method returns the empty filters array');
// @Test: ->addFilter()
$fc = new Sonata_FilterChain();
$fc->addFilter($fooFilter);
$fc->addFilter($barFilter);
$fc->addFilter($bazFilter);
$t->is($fc->getFilters(), array($fooFilter, $barFilter, $bazFilter), 'All filters were added correctly');
// @Test: ->processFilters()
$request = new Sonata_Request();
$response = new Sonata_Response();
$fooFilter = $t->mock('FooFilter');
$fooFilter->execute($request, $response)->once();
$fooFilter->replay();
$barFilter = $t->mock('BarFilter');
$barFilter->execute($request, $response)->once();
$barFilter->replay();
$bazFilter = $t->mock('BazFilter');
$bazFilter->execute($request, $response)->once();
$bazFilter->replay();
$fc = new Sonata_FilterChain();
$fc->addFilter($fooFilter);
$fc->addFilter($barFilter);
$fc->addFilter($bazFilter);
$fc->processFilters($request, $response);
$fooFilter->verify();
// @Test: Countable Interface
开发者ID:b00giZm,项目名称:sonata-framework,代码行数:31,代码来源:Sonata_FilterChainTest.php

示例2: LimeTest

/*
 * 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
$executable = new LimeExecutable(LimeExecutable::php() . ' %file%');
$file = tempnam(sys_get_temp_dir(), 'lime');
$output = $t->mock('LimeOutputInterface');
$input = new LimeInputTap($output);
// @After
$file = null;
$output = null;
$input = null;
// @Test: Successful tests are passed to pass()
// fixtures
$output->pass('A passed test', '', 0, '', '');
$output->replay();
// test
$input->parse("ok 1 - A passed test\n");
// assertions
$t->ok($input->done(), 'The input is done');
// @Test: Successful tests without message are passed to pass()
// fixtures
开发者ID:b00giZm,项目名称:lime,代码行数:30,代码来源:LimeInputTapTest.php

示例3: initializePostFilterChain

    {
        return $this->preFilterChainMock;
    }
    protected function initializePostFilterChain()
    {
        return $this->postFilterChainMock;
    }
}
$fh = fopen(dirname(__FILE__) . '/../fixtures/controllers/ArticleController.class.php', 'wb');
fputs($fh, '<?php class ArticleController extends Sonata_Controller_Action {} ?>');
fclose($fh);
$fh = fopen(dirname(__FILE__) . '/../fixtures/controllers/InvalidController.class.php', 'wb');
fputs($fh, '<?php class InvalidController {} ?>');
fclose($fh);
// @Before
$requestMock = $t->mock('Sonata_Request');
$responseMock = $t->mock('Sonata_Response');
$routeMapMock = $t->mock('Sonata_RouteMap');
$templateViewMock = $t->mock('Sonata_TemplateView');
$preFilterChainMock = $t->mock('Sonata_FilterChain');
$postFilterChainMock = $t->mock('Sonata_FilterChain');
$containerMock = $t->mock('sfServiceContainerInterface');
$containerMock->getService('request')->returns($requestMock);
$containerMock->getService('response')->returns($responseMock);
$containerMock->getService('route_map')->returns($routeMapMock);
$containerMock->getService('template_view')->returns($templateViewMock);
$containerMock->replay();
$dispatcher = new DispatcherHelper($containerMock, $preFilterChainMock, $postFilterChainMock);
// @After
unset($requestMock);
unset($responseMock);
开发者ID:b00giZm,项目名称:sonata-framework,代码行数:31,代码来源:Sonata_DispatcherTest.php

示例4: fooAction

    {
        return $this->varHolderMock;
    }
    public function fooAction()
    {
    }
    public function barAction()
    {
        return self::ACTION_FAILURE;
    }
    public function myBar()
    {
    }
}
// @Before
$requestMock = $t->mock('Sonata_Request');
$responseMock = $t->mock('Sonata_Response');
$varHolderMock = $t->mock('Sonata_ParameterHolder');
$templateVewMock = $t->mock('Sonata_TemplateView');
$fooController = new FooController($requestMock, $responseMock, $varHolderMock);
// @After
unset($requestMock);
unset($responseMock);
unset($varHolderMock);
unset($templateVewMock);
// @Test: ->dispatch()
// @Test: general
try {
    $fooController->dispatch('fail', $templateVewMock);
    $t->fail('No code should be executed after calling non-existing actions');
} catch (Sonata_Exception_Controller_Action $ex) {
开发者ID:b00giZm,项目名称:sonata-framework,代码行数:31,代码来源:Sonata_Controller_ActionTest.php

示例5: tearDown

    public function tearDown()
    {
        $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();
开发者ID:b00giZm,项目名称:lime,代码行数:31,代码来源:LimeTestCaseTest.php

示例6: registerRoutes

        return array('config' => dirname(__FILE__) . '/../config', 'controllers' => dirname(__FILE__) . '/../controllers', 'templates' => dirname(__FILE__) . '/../templates');
    }
    public function registerRoutes(Sonata_RouteMap $map)
    {
    }
    public function registerPreFilters()
    {
        return array();
    }
    public function registerPostFilters()
    {
        return array();
    }
}
// @Before
$containerMock = $t->mock('sfContainerInterface');
$dispatcherMock = $t->mock('Sonata_Dispatcher');
$app = new SonataAppHelper($containerMock);
$app->setDispatcherMock($dispatcherMock);
// @After
unset($containerMock);
unset($dispatcherMock);
unset($preFilterChainMock);
unset($postFilterChainMock);
unset($app);
// @Test: ->run()
$requestMock = $t->mock('Sonata_Reqeust');
$responseMock = $t->mock('Sonata_Response');
$routeMapMock = $t->mock('Sonata_RouteMap');
$templateViewMock = $t->mock('Sonata_TemplateView');
$containerMock->getService('request')->returns($requestMock)->once();
开发者ID:b00giZm,项目名称:sonata-framework,代码行数:31,代码来源:Sonata_AppTest.php

示例7: 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->replay();
$output = new LimeOutputTap($printer, $configuration);
// @After
$printer = null;
$output = null;
// @Test: focus() prints the filename
$printer->printLine('# /test/file', LimePrinter::INFO);
$printer->replay();
// test
$output->focus('/test/file');
// @Test: focus() prints the filename only once
$printer->printLine('# /test/file', LimePrinter::INFO)->once();
$printer->replay();
// test
$output->focus('/test/file');
开发者ID:b00giZm,项目名称:lime,代码行数:31,代码来源:LimeOutputTapTest.php

示例8: 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.
 */
$t = new LimeTest();
$t->diag('The before callbacks are called before each test method');
// fixtures
$mock = $t->mock('Mock', array('strict' => true));
$r = new LimeTestRunner();
$r->addBefore(array($mock, 'setUp'));
$r->addTest(array($mock, 'testDoSomething'), 'Do something', '/test/file', 11);
$r->addTest(array($mock, 'testDoSomethingElse'), 'Do something else', '/test/file', 22);
$mock->setUp('Do something', '/test/file', 11);
$mock->testDoSomething();
$mock->setUp('Do something else', '/test/file', 22);
$mock->testDoSomethingElse();
$mock->replay();
// test
$r->run();
$t->diag('The after callbacks are called before each test method');
// fixtures
$mock = $t->mock('Mock', array('strict' => true));
$r = new LimeTestRunner();
$r->addAfter(array($mock, 'tearDown'));
开发者ID:b00giZm,项目名称:lime,代码行数:31,代码来源:LimeTestRunnerTest.php

示例9: execute

 *
 * @author Pascal Cremer <b00giZm@gmail.com>
 */
require_once dirname(__FILE__) . '/bootstrap.php';
$t = new LimeTest();
// @BeforeAll
class TestFilter extends Sonata_Filter
{
    public function execute(Sonata_Request $request, Sonata_Response $response)
    {
    }
}
class TestFilterDecorator extends Sonata_Filter_Decorator
{
    public function doExecute(Sonata_Request $request, Sonata_Response $response)
    {
    }
}
// @Before
$request = new Sonata_Request();
$response = new Sonata_Response();
// @After
unset($request);
unset($response);
// @Test: ->execute()
$filter = $t->mock('TestFilter');
$filter->execute($request, $response)->once();
$filter->replay();
$filterDecorator = new TestFilterDecorator($filter);
$filterDecorator->execute($request, $response);
$filter->verify();
开发者ID:b00giZm,项目名称:sonata-framework,代码行数:31,代码来源:Sonata_Filter_DecoratorTest.php


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