How to use controlNextNewMock method of controller class

Best Atoum code snippet using controller.controlNextNewMock

controller.php

Source:controller.php Github

copy

Full Screen

...9class controller extends test\adapter10{11 protected $mock = null;12 protected $iterator = null;13 protected static $controlNextNewMock = null;14 private $disableMethodChecking = false;15 public function __construct()16 {17 parent::__construct();18 $this->setIterator()->controlNextNewMock();19 }20 public function __set($method, $mixed)21 {22 $this->checkMethod($method);23 return parent::__set($method, $mixed);24 }25 public function __get($method)26 {27 $this->checkMethod($method);28 return parent::__get($method);29 }30 public function __isset($method)31 {32 $this->checkMethod($method);33 return parent::__isset($method);34 }35 public function __unset($method)36 {37 $this->checkMethod($method);38 parent::__unset($method);39 $this->invokers[strtolower($method)] = null;40 return $this;41 }42 public function setIterator(controller\iterator $iterator = null)43 {44 $this->iterator = $iterator ?: new controller\iterator();45 $this->iterator->setMockController($this);46 return $this;47 }48 public function getIterator()49 {50 return $this->iterator;51 }52 public function disableMethodChecking()53 {54 $this->disableMethodChecking = true;55 return $this;56 }57 public function getMock()58 {59 return $this->mock;60 }61 public function getMockClass()62 {63 return ($this->mock === null ? null : get_class($this->mock));64 }65 public function getMethods()66 {67 return ($this->mock === null ? array() : $this->mock->getMockedMethods());68 }69 public function methods(\closure $filter = null)70 {71 $this->iterator->resetFilters();72 if ($filter !== null)73 {74 $this->iterator->addFilter($filter);75 }76 return $this->iterator;77 }78 public function methodsMatching($regex)79 {80 return $this->iterator->resetFilters()->addFilter(function($name) use ($regex) { return preg_match($regex, $name); });81 }82 public function getCalls($method = null, array $arguments = null, $identical = false)83 {84 if ($method !== null)85 {86 $this->checkMethod($method);87 }88 return parent::getCalls($method, $arguments, $identical);89 }90 public function control(mock\aggregator $mock)91 {92 $mockClass = get_class($mock);93 if ($this->mock !== $mock)94 {95 $this->mock = $mock;96 $methods = $this->getMethods();97 if ($this->disableMethodChecking === false)98 {99 foreach (array_keys($this->invokers) as $method)100 {101 if (in_array($method, $methods) === false)102 {103 if (in_array('__call', $methods) === false)104 {105 throw new exceptions\logic('Method \'' . $this->getMockClass() . '::' . $method . '()\' does not exist');106 }107 else if (isset($this->invokers['__call']) === false)108 {109 $this->invokers['__call'] = null;110 $this->set__call();111 }112 }113 }114 }115 foreach ($methods as $method)116 {117 if (isset($this->invokers[$method]) === false)118 {119 $this->invokers[$method] = null;120 }121 }122 }123 $mock->setMockController($this);124 if (self::$controlNextNewMock === $this)125 {126 self::$controlNextNewMock = null;127 }128 return $this;129 }130 public function controlNextNewMock()131 {132 self::$controlNextNewMock = $this;133 return $this;134 }135 public function notControlNextNewMock()136 {137 if (self::$controlNextNewMock === $this)138 {139 self::$controlNextNewMock = null;140 }141 return $this;142 }143 public function reset()144 {145 $this->mock = null;146 return parent::reset();147 }148 public function invoke($method, array $arguments = array())149 {150 $this->checkMethod($method);151 if (isset($this->{$method}) === false)152 {153 throw new exceptions\logic('Method ' . $method . '() is not under control');154 }155 return parent::invoke($method, $arguments);156 }157 public static function get()158 {159 $instance = self::$controlNextNewMock;160 if ($instance !== null)161 {162 self::$controlNextNewMock = null;163 }164 return $instance;165 }166 protected function checkMethod($method)167 {168 if ($this->mock !== null && $this->disableMethodChecking === false && array_key_exists(strtolower($method), $this->invokers) === false)169 {170 if (array_key_exists('__call', $this->invokers) === true)171 {172 $this->set__call();173 }174 else if (isset($this->__call) === false)175 {176 throw new exceptions\logic('Method \'' . $this->getMockClass() . '::' . $method . '()\' does not exist');...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in controller

Trigger controlNextNewMock code on LambdaTest Cloud Grid

Execute automation tests with controlNextNewMock on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful