phpunit

Laravel testing on demand notification

拜拜、爱过 提交于 2019-12-13 14:45:56
问题 I have a slack notification class that sends a message inside our company slack account, in a specific channel, every time an user performs the activation process. The system works, but it's manually tested and that's not cool. The notification is sent by a listener attached to an UserHasBeenActivated event, the listener is the following: public function handle(UserHasBeenActivated $event) { Notification::route("slack", config("services.slack.user.url")) ->notify(new UserActivated($event-

Testing iterables in PHPUnit

烂漫一生 提交于 2019-12-13 14:36:19
问题 In PHPUnit it quite easy to assert that two arrays contain the same value: $this->assertEquals( [1, 2, 3], [1, 2, 3] ); Recent versions of PHP made usage of Iterators and Generators a lot more attractive, and PHP 7.1 introduced the iterable pseudo-type. That means I can write functions to take and return iterable without binding to the fact I am using a plain old array or using a lazy Generator . How do I assert the return value of functions returning an iterable ? Ideally I could do

Can I make PHPUnit fail if the code throws a notice?

帅比萌擦擦* 提交于 2019-12-13 14:28:30
问题 It doesn't appear to do it by default, and I don't see any switch for it either. This is PHPUnit 2.3.5, and PHP 5.2.0-8. 回答1: You want to upgrade to a more recent version of PHPUnit, have a look at http://www.phpunit.de/. 回答2: function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } set_error_handler("exception_error_handler"); 回答3: Your available option appears to be using set_error_handler() to override the

Why Netbean ignore PHPUnit testsuite from the XML config?

蹲街弑〆低调 提交于 2019-12-13 14:15:32
问题 I've setup netbean to use my config.xml file, and it works well except for the testsuites part that is completly ignored by netbean. It look like netbean try to execute this command: phpunit -c config.xml path/to/tests/ instead of just: phpunit -c config.xml How can I configure netbean in order to handler the testsuites definition inside a phpunit XML configuration ? 回答1: Seems to be a bug of netbeans, see Bug 199072 - NetBeans ignores PHPUNIT.XML and runs tests from all folders. 回答2:

Replace Symfony service in tests for php 7.2

六月ゝ 毕业季﹏ 提交于 2019-12-13 14:07:42
问题 I'm trying to upgrade my application working on Symfony 3.3 and php 7.1 to php 7.2, but I encountered tons of DEPRECATED messages when I run phpunit. Most annoying is: The "user.user_service" service is already initialized, replacing it is deprecated since Symfony 3.3 and will fail in 4.0: 7x This is because I have this lines at setUp method: $this->userService = $this->getMockBuilder(UserService::class) ->setMethods(['update']) ->getMock(); $container->set('user.user_service', $this-

How to configure codeception for functional test with Symfony2?

谁说我不能喝 提交于 2019-12-13 14:01:29
问题 I'm using this functional.suite.yml: class_name: FunctionalTester modules: enabled: - Symfony2 - \Helper\Functional I build and run tests and get: Trying to Log in and see result (LoginCept)... PHP Fatal error: Undefined class constant 'UNKNOWN' in phar:///usr/local/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestResult.php on line 592 PHP Stack trace: PHP 1. {main}() /usr/local/bin/codecept:0 PHP 2. require_once() /usr/local/bin/codecept:7 PHP 3. Symfony\Component\Console\Application-

PHP Fatal error: Class 'CTestCase' not found in

ⅰ亾dé卋堺 提交于 2019-12-13 13:14:56
问题 Just trying to run a simple test on my local box but i get the following error: PHP Fatal error: Class 'CTestCase' not found in .... when running $ phpunit UserTest I guess my configuration must be missing something? I just can't figure out what. Using: OSX 10.6.7 PHP 5.3.4 PHPUnit 3.5.13 Yii 1.1.7 回答1: Make sure you run phpunit at the same directory where your phpunit.xml is. :) 回答2: The error message is telling you that the class CTestCase cannot be located. PHPUnit accepts an --include

How to find the reason for a risky test in PHPUnit

一世执手 提交于 2019-12-13 11:53:33
问题 From time to time I get a risky test in PHPUnit. Usually I can find the reason for a risky test. But the task can be time consuming, because I do not see any messages from PHPUnit, why a test is marked as risky. I only get something like this: PHPUnit 4.4.5 by Sebastian Bergmann. Configuration read from phpunit.xml.dist R...................R.R... Time: 11,91 seconds, Memory: 42,50Mb OK, but incomplete, skipped, or risky tests! Tests: 26, Assertions: 32, Risky: 3. Is there any option to tell

Aggregating code coverage from several executions of PHPUnit

人走茶凉 提交于 2019-12-13 11:34:22
问题 I have been working with PHPUnit for a little while now, and it's starting to look like I may need to break my tests up into groups that would run as separate executions of phpunit . The main reason for this is that most of my tests need to run in separate processes, while some actually cannot be run in separate processes because of an issue documented here. What I would like to do is write a bash script that fires off several executions of phpunit , each configured to run different tests

need help for the zend unit test

為{幸葍}努か 提交于 2019-12-13 06:58:58
问题 I am using unit test to test zend project, this is application.ini [production] phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 resources.frontController.params.displayExceptions = 0 includePaths.library = APPLICATION_PATH "/../library" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" appnamespace = "Application" ; modules resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController