phpunit

php vendor\bin\phpunit is printing in console a text

房东的猫 提交于 2019-12-24 03:29:49
问题 I have been trying to use PHPUnit to test my app, (I installed it via Composer) but when I was trying to execute the tests that I have in my directory called "Tests" in this way: @myappsite$:php vendor\bin\phpunit Tests It just printed the content of vendor\bin\ phpunit : SRC_DIR="`pwd`" cd "`dirname "$0"`" cd "../phpunit/phpunit" BIN_TARGET="`pwd`/phpunit" cd "$SRC_DIR" "$BIN_TARGET" "$@" Somebody that has ran into this problem before and can help me please. Thanks by advance. 回答1: Ok, The

Cakephp 3 - MissingDatasourceConfigException when running phpunit test

前提是你 提交于 2019-12-24 03:24:02
问题 I am trying to run some unit tests in CakePHP 3 with PHPUnit 4.7.3, but I`m getting the following error: PHPUnit 4.7.3 by Sebastian Bergmann and contributors. There was 1 error: 1) App\Test\TestCase\Model\Table\MoviesTableTest::testFindMoviesByGenre Cake\Datasource\Exception\MissingDatasourceConfigException: The datasource configuration "default" was not found. C:\xampp\htdocs\movie-pal\vendor\cakephp\cakephp\src\Datasource\ConnectionManager.php:188 C:\xampp\htdocs\movie-pal\vendor\cakephp

Change window size PHPUnit Selenium2TestCase

混江龙づ霸主 提交于 2019-12-24 03:22:47
问题 I need to maximize my window when the test start and I found this Class PHPUnit_Extensions_Selenium2TestCase_Window. So I tried to use the method $this->maximize() but I only get BadMethodCallException: The command 'maximize' is not existent or not supported yet. Anyone know how to do this? 回答1: On selenium2TestCase v1.3.3 it's $this->prepareSession()->currentWindow()->maximize(); 来源: https://stackoverflow.com/questions/18099243/change-window-size-phpunit-selenium2testcase

Testing exception PHPUnit

这一生的挚爱 提交于 2019-12-24 03:06:04
问题 So I playing around with PHPUnit and would like to get some insight to the output that PHPUnit generates when I try to test for an Exception. I am confused as to why I am getting a failed test. Here is my test: class ConfigTest extends PHPUnit_Framework_Testcase { public function testTrueIfJobGivenExists() { $conf = Config::getInstance('test1.php', new Database()); $setup = $conf->getConfig(); $this->assertTrue($setup); } /** * @expectedException Exception */ public function

PHPUnit mocked method called 0 times while it should be called once

泄露秘密 提交于 2019-12-24 03:05:56
问题 I'm new to unit-testing and I'm having problems understanding the mocking object in phpunit. I have the following function: public function createPaymentStatement() { $tModel = new \FspInvoice\Model\Transaction(); $paymentsArr = $this->transactionGateway->getTransactionWithStatus($tModel::SETTLED); $result = false; if(is_array($paymentsArr)){ //some code here $result = $psArr; } return $result; } And now the uni-test for the function above: public function

Test that method is called with some parameters, among others

拈花ヽ惹草 提交于 2019-12-24 03:00:31
问题 I'm testing a method with phpunit and I have the following scenario: method 'setParameter' is called an unkown amount of times method 'setParameter' is called with different kinds of arguments among the various arguments method 'setParameter' MUST be called with a set of arguments. I've tried doing it this way: $mandatoryParameters = array('param1', 'param2', 'param3'); foreach ($mandatoryParameters as $parameter) { $class->expects($this->once()) ->method('setParameter') ->with($parameter); }

Why is PHPUnit creating the output “S” for a test that passes?

南笙酒味 提交于 2019-12-24 02:55:11
问题 I'm using PHPUnit in Eclipse IDE and this is the output when running my unit test: PHPUnit 3.7.28 by Sebastian Bergmann. .S......... Time: 190 ms, Memory: 5.50Mb OK (10 tests, 45 assertions) The output has an S which suggests that a test is being skipped. However, there is no message " Skipped: 1 ". According to the manual, the test output should look like this: .S......... Time: 190 ms, Memory: 5.50Mb 1) UnitTest_Directory_Test::testBenthicCover The MySQLi extension is not available. /home

PHPUnit: continue after die, expect “die” or somehow handle die()? [duplicate]

為{幸葍}努か 提交于 2019-12-24 00:58:59
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How do you use PHPUnit to test a function if that function is supposed to kill PHP? I'm writing some unit tests. The system I'm currently testing is a web-app in an MVC framework. If we want to render pages without the site-skin system we've traditionally run our code as usual, but printed a "die();" statement at the end of the function to exit before the rest of the website renders. Well now that we're adding

PHPUnit - How to mock the class inside another class's method?

两盒软妹~` 提交于 2019-12-24 00:44:35
问题 How can I mock the class inside another class's method? For instance, protected function buildRequest($params) { return new \Request(); } public function getPayload($params) { $request = $this->buildRequest($params); .... } Can I mock buildRequest ? I need to test this method getPayload($params) but I get this error: Class 'Request' not found in... 回答1: One option is to introduce a factory that would create a Request instance, and inject the factory into your class. You'd be able to stub the

CakePHP “with” method in mock object don't Work

强颜欢笑 提交于 2019-12-24 00:42:27
问题 I'm trying testing my application using CakePHP 2.2 RC1, in the certain action of my controller i need one information of Auth object, in my test i have created an mock object for the Auth component, but when i call the method with my mock object become invalid, when i don't put this everything works fine. Below the mock object wich dont work $this->controller->Auth ->staticExpects($this->any()) ->method('user') ->with('count_id') ->will($this->returnValue(9)); Thanks for your attention guys.