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


PHP Mock::Generate方法代码示例

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


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

示例1: setUp

<?php

Mock::Generate('Csv_Dialect', 'Mock_Dialect');
Mock::Generate('Csv_Dialect', 'Mock_Dialect_Two');
/**
 * Csv Writer unit tests
 */
class Test_Of_Csv_Writer extends UnitTestCase
{
    public function setUp()
    {
        $this->dialect = new Mock_Dialect();
        $this->dialect->delimiter = ",";
        $this->dialect->quotechar = '"';
        $this->dialect->escapechar = "\\";
        $this->dialect->skipblanklines = true;
        $this->dialect->lineterminator = "\r\n";
        $this->file = realpath('../') . '/tests/data/writer1.csv';
        $this->file2 = realpath('../') . '/tests/data/writer2.csv';
        $this->file3 = realpath('../') . '/tests/data/writer3.csv';
        $this->testdata = array(array('This contains the quote "character" because it\'s cool like that', 1, 2), array("This one contains some commas, and some \t\t tabs and stuff", 45, 2009), array('I have "several" different kinds of \'quotes\'', 133, 2234234), array("I am regular\n\r text but with a line break in me", 21, "Num123412342"));
    }
    public function tearDown()
    {
        if (file_exists($this->file)) {
            unlink($this->file);
        }
        if (file_exists($this->file2)) {
            unlink($this->file2);
        }
        if (file_exists($this->file3)) {
开发者ID:rettichschnidi,项目名称:naturvielfalt,代码行数:31,代码来源:Writer.php

示例2: testConnectionChoosesOnlyOneWorkingConnection

<?php

if (!class_exists("FullMockConnection")) {
    Mock::Generate("DummyConnection", "FullMockConnection");
}
class TestOfMultiConnection extends UnitTestCase
{
    public function testConnectionChoosesOnlyOneWorkingConnection()
    {
        $mock1 = new FullMockConnection();
        $mock1->setReturnValue("isAlive", false);
        $mock1->expectOnce("start");
        $mock1->expectNever("read");
        $mock1->expectNever("write");
        $mock2 = new FullMockConnection();
        $mock2->setReturnValue("isAlive", true);
        $mock2->expectOnce("start");
        $mock2->expectOnce("read");
        $mock2->expectCallCount("write", 3);
        $mock2->expectAt(0, "write", array("foo", "*"));
        $mock2->expectAt(1, "write", array("bar", "*"));
        $mock2->expectAt(2, "write", array("zip", "*"));
        $mock3 = new FullMockConnection();
        $mock3->setReturnValue("isAlive", true);
        $mock3->expectNever("start");
        $mock3->expectNever("read");
        $mock3->expectNever("write");
        $multi = new Swift_Connection_Multi();
        $multi->addConnection($mock1, "mock1");
        $multi->addConnection($mock2, "mock2");
        $multi->addConnection($mock3, "mock3");
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:31,代码来源:TestOfMultiConnection.php

示例3: dirname

Swift_ClassLoader::load("Swift_Events_BeforeCommandListener");
Swift_ClassLoader::load("Swift_Events_CommandListener");
Swift_ClassLoader::load("Swift_Events_ResponseListener");
Swift_ClassLoader::load("Swift_Events_ConnectListener");
Swift_ClassLoader::load("Swift_Events_DisconnectListener");
Swift_ClassLoader::load("Swift_Plugin_AntiFlood");
Swift_ClassLoader::load("Swift_Plugin_BandwidthMonitor");
Swift_ClassLoader::load("Swift_Plugin_Throttler");
Swift_ClassLoader::load("Swift_Plugin_VerboseSending");
Swift_ClassLoader::load("Swift_Plugin_ConnectionRotator");
Swift_ClassLoader::load("Swift_Plugin_Decorator");
Swift_ClassLoader::load("Swift_Message_Headers");
Swift_ClassLoader::load("Swift_CacheFactory");
Swift_ClassLoader::load("Swift_Log_DefaultLog");
Swift_ClassLoader::load("Swift_Message_Encoder");
Swift_ClassLoader::load("Swift_Cache_JointOutputStream");
require_once TestConfiguration::SWIFT_LIBRARY_PATH . "/Swift/Authenticator/@PopB4Smtp.php";
Swift_ClassLoader::load("Swift_Authenticator_PopB4Smtp_Pop3Connection");
require_once dirname(__FILE__) . "/AbstractTestWithSend.php";
require_once dirname(__FILE__) . "/AbstractTestOfCache.php";
require_once dirname(__FILE__) . "/AbstractTestOfAuthenticator.php";
require_once dirname(__FILE__) . "/stubs/MimeExtension.php";
require_once dirname(__FILE__) . "/stubs/DummyConnection.php";
Mock::Generate("DummyConnection", "FullMockConnection");
Mock::Generate("Swift_Connection_Rotator", "MockRotatorConnection");
Mock::Generate("Swift_Message", "MockMessage");
Mock::Generate("Swift_Events_SendListener", "MockSendListener");
Mock::Generate("Swift_Connection_SMTP", "MockSMTPConnection");
Mock::GeneratePartial("Swift_Connection_SMTP", "MockSMTPConnectionAuth", array("read", "write", "isAlive", "start", "stop"));
Mock::Generate("Swift_Message_Headers", "MockHeaders");
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:30,代码来源:common.php

示例4: array

<?php

/**
 * Swift Mailer Unit Test for the Swift_Authenticator Interface.
 * @package Swift
 * @subpackage Tests
 * @author Chris Corbyn <chris@w3style.co.uk>
 */
Mock::Generate("Swift_Authenticator", "MockAuthenticator");
Mock::GeneratePartial("Swift_Connection_SMTP", "PartialSmtpConnection", array("read"));
/**
 * Swift Mailer Unit Test for the Swift_Authenticator Interface.
 * @package Swift
 * @subpackage Tests
 * @author Chris Corbyn <chris@w3style.co.uk>
 */
class TestOfAuthenticator extends UnitTestCase
{
    /**
     * Checks that the interface is actually invoked when needed.
     */
    public function testAuthenticatorIsInvokedIfSMTPUsernameAndPasswordSet()
    {
        try {
            $auth = new MockAuthenticator();
            $auth->setReturnValue("getAuthExtensionName", "FOO");
            $auth->expectOnce("isAuthenticated", array("foo", "bar", "*"));
            $smtp = new PartialSmtpConnection();
            $smtp->setExtension("AUTH", array("FOO"));
            $smtp->setUsername("foo");
            $smtp->setPassword("bar");
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:31,代码来源:TestOfAuthenticator.php

示例5: getWorkingMockConnection

<?php

if (!class_exists("FullMockConnection")) {
    Mock::Generate("DummyConnection", "FullMockConnection");
}
Mock::Generate("Swift_Events_SendListener", "MockSendListener");
Mock::Generate("Swift_Events_BeforeSendListener", "MockBeforeSendListener");
Mock::Generate("Swift_Events_CommandListener", "MockCommandListener");
Mock::Generate("Swift_Events_BeforeCommandListener", "MockBeforeCommandListener");
Mock::Generate("Swift_Events_ResponseListener", "MockResponseListener");
Mock::Generate("Swift_Events_ConnectListener", "MockConnectListener");
Mock::Generate("Swift_Events_DisconnectListener", "MockDisconnectListener");
class TestOfPluginAPI extends UnitTestCase
{
    /** Get a mock connection for testing
     * @param int The number emails you expect to send
     * @return FullMockConnection
     */
    protected function getWorkingMockConnection($send = 1)
    {
        $count = 0;
        $conn = new FullMockConnection();
        $conn->setReturnValueAt($count++, "read", "220 xxx ESMTP");
        $conn->setReturnValueAt($count++, "read", "250-Hello xxx\r\n250 HELP");
        for ($i = 0; $i < $send; $i++) {
            $conn->setReturnValueAt($count++, "read", "250 Ok");
            $conn->setReturnValueAt($count++, "read", "250 Ok");
            $conn->setReturnValueAt($count++, "read", "354 Go ahead");
            $conn->setReturnValueAt($count++, "read", "250 Ok");
        }
        $conn->setReturnValueAt($count++, "read", "221 Bye");
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:31,代码来源:TestOfPluginAPI.php

示例6: setItem

<?php

class Orm_DataMapper_Mapping_Object
{
    public $item;
    function setItem($item)
    {
    }
    function set()
    {
    }
    function get()
    {
    }
}
Mock::Generate('Orm_DataMapper_Mapping_Object', 'Orm_DataMapper_Mapping_MockObject');
class Orm_DataMapper_Mapping_Test extends UnitTestCase
{
    public function setUp()
    {
        $this->object = new Orm_DataMapper_Mapping_MockObject();
        $this->setMethod = 'setDescription';
        $this->getMethod = 'getDescription';
        $this->property = 'description';
        $this->column = 'table.description';
        $this->alias = 'description';
        $this->table = 'items';
        #		public function __construct ($getMethod='', $setMethod='', $property='', $column='', $table='', $key = false, $callback = array(), $param = false)	{
        $this->mapping = new A_Orm_DataMapper_Mapping($this->getMethod, $this->setMethod, $this->property, array($this->alias => $this->column), $this->table, true);
    }
    public function testGetSetMethod()
开发者ID:TheProjecter,项目名称:skeleton,代码行数:31,代码来源:MappingTest.php

示例7: getWorkingMockConnection

<?php

/**
 * SwiftMailer Unit Testing Component.
 * Provides a testcase with functionality to get a Working Mock Connection.
 * @package Swift
 * @subpackage Tests
 * @author Chris Corbyn <chris@w3style.co.uk>
 */
Mock::Generate("Swift_Connection", "FullMockConnection");
/**
 * SwiftMailer Abstract test with sending capabilities.
 * Provides a testcase with functionality to get a Working Mock Connection.
 * @package Swift
 * @subpackage Tests
 * @author Chris Corbyn <chris@w3style.co.uk>
 */
abstract class AbstractTestWithSend extends UnitTestCase
{
    /**
     * Get a mock connection for testing.
     * The mock will be set up to send to X addresses (sccuessfully).
     * The mock can also be configured to reconnect after X emails have been sent.
     * @param int The number emails you expect to send
     * @param Swift_Connection A mocked object which has not been setup yet, optional
     * @param int The number of emails to send before reconnecting, optional
     * @param int The maximum number of times the connection will re-connect, optional
     * @param boolean True if the same email is copied to all recipients
     * @return FullMockConnection
     */
    protected function getWorkingMockConnection($send = 1, $conn = null, $reconnect_at = 0, $max_reconnect = 0, $duplicate = false)
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:31,代码来源:AbstractTestWithSend.php

示例8: setUp

<?php

Mock::Generate('A_Db_Mysql', 'Pagination_Adapter_MockDb');
Mock::Generate('A_Db_Recordset_Mysql', 'Pagination_Adapter_MockResult');
class Pagination_Adapter_DbTest extends UnitTestCase
{
    public function setUp()
    {
        $this->db = new Pagination_Adapter_MockDb();
        $this->result = new Pagination_Adapter_MockResult();
        $this->db->setReturnValue('query', $this->result);
        $this->db->setReturnValue('limit', 'SELECT * FROM pages LIMIT 10');
        $this->db->expect('limit', array('*', 10, 9));
        // 9 because LIMIT offset is zero based
        $this->row = array('one', 'two', 'three', 'four');
        $this->query = 'SELECT * FROM pages';
        $this->adapter = new A_Pagination_Adapter_Db($this->db, $this->query);
    }
    public function testGetNumItemsDelegatesToDatasource()
    {
        $this->db->expectOnce('query');
        $this->adapter->getNumItems();
    }
    public function testGetNumItemsReplacesAsteriskWithCount()
    {
        $this->db->expectOnce('query', array('SELECT COUNT(*) AS count FROM pages'));
        $this->adapter->getNumItems();
    }
    public function testGetNumItemsReturnsValueFromDatasource()
    {
        $this->result->setReturnValue('isError', false);
开发者ID:TheProjecter,项目名称:skeleton,代码行数:31,代码来源:DbTest.php

示例9: setUp

<?php

Mock::Generate('A_Datetime_Range');
Mock::Generate('A_Datetime_Duration');
class DatetimeTest extends UnitTestCase
{
    function setUp()
    {
    }
    function TearDown()
    {
    }
    function testDatetime_parseDate()
    {
        $datetime = new A_Datetime();
        $datetime->parseDate('2001/12/20');
        $this->assertEqual($datetime->getDate(), '2001-12-20');
        $datetime->parseDate('12//20//2001');
        $this->assertEqual($datetime->getDate(), '2001-12-20');
        $datetime->parseDate('20.12.2001');
        $this->assertEqual($datetime->getDate(), '2001-12-20');
        $datetime->parseDate('12/20/01');
        $this->assertEqual($datetime->getDate(), '2001-12-20');
        $datetime->parseDate('12/20/01');
        $this->assertEqual($datetime->getDate(), '2001-12-20');
        $datetime->parseDate('1/2/01');
        $this->assertEqual($datetime->getDate(), '2001-02-01');
        $datetime->parseDate('020301');
        $this->assertEqual($datetime->getDate(), '2001-03-02');
        $datetime->parseDate('19990706');
        $this->assertEqual($datetime->getDate(), '1999-07-06');
开发者ID:TheProjecter,项目名称:skeleton,代码行数:31,代码来源:DatetimeTest.php

示例10: setUp

<?php

class DomainObject
{
}
Mock::Generate('DomainObject', 'MockDomainObject');
class Orm_DataMapperTest extends UnitTestCase
{
    public function setUp()
    {
        $db = true;
        $this->mapper = new A_Orm_DataMapper($db, 'MockObject', 'pages');
        $this->mapper->mapMethods('getTitle', 'setTitle')->toColumn('title');
        $this->mapper->mapProperty('description')->toColumn('description', 'items');
        $this->mapper->mapProperty('body')->toColumn(array('body' => 'page_body'));
        $this->object = $this->mapper->load(array('title' => 'Hello', 'description' => 'Cheesy'));
    }
    public function testLoadReturnsCorrectClass()
    {
        $this->assertIsA($this->object, 'MockObject');
    }
    public function testMapMethodsToColumn()
    {
        $this->assertEqual($this->object->getTitle(), 'Hello');
    }
    public function testMapPropertytoColumn()
    {
        $this->assertEqual($this->object->description, 'Cheesy');
    }
    public function testGetTableNames()
    {
开发者ID:TheProjecter,项目名称:skeleton,代码行数:31,代码来源:DataMapperTest.php


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