/**
  * Get a singleton instance of this MockGenerator.
  * @return Yay_MockGenerator
  */
 public static function getInstance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 private function _getInvocationSignature()
 {
     $class = Yay_MockGenerator::getInstance()->reverseNamingScheme(get_class($this->_object));
     if (isset($this->_method)) {
         $method = $this->_method;
     } else {
         $method = '<any method>';
     }
     if (!empty($this->_matchers)) {
         $args = array();
         foreach ($this->_matchers as $matcher) {
             $args[] = $matcher->describeMatch('%s [%s]');
         }
         $params = implode(', ', $args);
     } else {
         $params = '';
     }
     return sprintf('%s::%s(%s)', $class, $method, $params);
 }
Example #3
0
<?php

/*
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
/**
 * YayMock include and bootstrap file.
 * @author Chris Corbyn
 */
require_once dirname(__FILE__) . '/classes/Yay.php';
Yay::setClassPath(dirname(__FILE__) . '/classes');
spl_autoload_register(array('Yay', 'autoload'));
Yay_MockGenerator::getInstance()->setMockTemplate(dirname(__FILE__) . '/mock.tpl.php');
//EOF
Example #4
0
 /**
  * Create a MockObject matching $typeHint.
  * If the $typeHint is an interface the Mock will implement the interface
  * and maintain the method signatures from that interface.
  * If the $typeHint is a class name the Mock will extend the class overriding
  * all public methods (HOWEVER, if the class contains final methods it is not
  * possible to override all methods and hence, the mock will have no specific
  * type.
  * @param string $typeHint
  * @return Yay_MockObject
  */
 public function mock($typeHint)
 {
     $className = $this->_generator->generateMock($typeHint);
     $reflector = new ReflectionClass($className);
     return $reflector->newInstance($this);
 }
 private function _getInvocationSignature()
 {
     $class = Yay_MockGenerator::getInstance()->reverseNamingScheme(get_class($this->_object));
     if (!empty($this->_arguments)) {
         $args = array();
         foreach ($this->_arguments as $arg) {
             $args[] = $this->_describeArgument($arg, '%s [%s]');
         }
         $params = implode(', ', $args);
     } else {
         $params = '';
     }
     return sprintf('%s::%s(%s)', $class, $this->_method, $params);
 }