I'm trying to Mock this class:Error wrote:Fatal error: Declaration of PartialSmtpConnectionIO::write() must be compatible with that of Swift_Connection::write() in /Users/d11wtq/PHPLibs/simpletest/mock_objects.php(1001) : eval()'d code on line 134
Code: Select all
<?php
/**
* Swift Mailer Connection Base
* All connection handlers extend this abstract class
* Please read the LICENSE file
* @author Chris Corbyn <chris@w3style.co.uk>
* @package Swift_Connection
* @license GNU Lesser General Public License
*/
/**
* Swift Connection Base class
* Lists methods which are required by any connections as well as providing some common functions.
* @package Swift_Connection
* @author Chris Corbyn <chris@w3style.co.uk>
*/
abstract class Swift_Connection
{
/**
* Any extensions the server might support
* @var array
*/
protected $extensions = array();
/**
* True if the connection is ESMTP.
* @var boolean
*/
protected $isESMTP = false;
/**
* Set an extension which the connection reports to support
* @param string Extension name
* @param array Attributes of the extension
*/
public function setExtension($name, $options=array())
{
$this->extensions[$name] = $options;
}
/**
* Check if a given extension has been set as available
* @param string The name of the extension
* @return boolean
*/
public function hasExtension($name)
{
return array_key_exists($name, $this->extensions);
}
/**
* Execute any needed logic after connecting and handshaking
*/
public function postConnect(Swift $instance) {}
/**
* Get the list of attributes supported by the given extension
* @param string The name of the connection
* @return array The list of attributes
* @throws Swift_ConnectionException If the extension cannot be found
*/
public function getAttributes($extension)
{
if ($this->hasExtension($extension))
{
return $this->extensions[$extension];
}
else
{
throw new Swift_ConnectionException(
"Unable to locate any attributes for the extension '" . $extension . "' since the extension cannot be found. " .
"Consider using hasExtension() to check.");
}
}
/**
* Returns TRUE if the connection needs a EHLO greeting.
* @return boolean
*/
public function getRequiresEHLO()
{
return $this->isESMTP;
}
/**
* Set TRUE if the connection needs a EHLO greeting.
* @param boolean
*/
public function setRequiresEHLO($set)
{
$this->isESMTP = (bool) $set;
}
/**
* Try to start the connection
* @throws Swift_ConnectionException If the connection cannot be started
*/
abstract public function start();
/**
* Return the contents of the buffer
* @return string
* @throws Swift_ConnectionException If the buffer cannot be read
*/
abstract public function read();
/**
* Write a command to the buffer
* @param string The command to send
* @throws Swift_ConnectionException If the write fails
*/
abstract public function write($command, $end="\r\n");
/**
* Try to stop the connection
* @throws Swift_ConnectionException If the connection cannot be closed/stopped
*/
abstract public function stop();
/**
* Check if the connection is up or not
* @return boolean
*/
abstract public function isAlive();
}Does anyone know how I can mock this class? I need to make expectations on values passed to write() so I cannot use a partial and exclude this method neither