simpletest

Real-world testing of CakePHP controllers?

扶醉桌前 提交于 2019-12-05 08:58:16
I'm writing a new application with CakePHP (just-released 1.2.4), using SimpleTest 1.0.1. I have read the relevant sections of the Cookbook , searched on the Bakery , and read Mark Story's postings on controller testing (the hard way and with mocks ). Unfortunately, none of this talks about real-world testing of non-trivial controllers. Lots of apps put areas of the site behind a login, yet I cannot figure out how to test the simple scenario of: guest access to protected page redirects? valid credentials sets expected session variables? invalid credentials re-displays login page with error

How to implement SimpleTest in Kohana

蹲街弑〆低调 提交于 2019-12-05 01:52:06
问题 My boss assigned me to learn how to use Kohana and implement simple test in that. We would like to use it as our framework for future projects. Being new to both KohanaPHP and SimpleTest, I can't figure out how to do even the simplest test of my helpers. I can't even find a single step-by-step tutorial on how to attach SimpleTest to Kohana. Anyone here have an idea? 回答1: We've created a SimpleTest_controller in Kohana and it gets the test from a directory tests define ( 'SIMPLE_TEST', '..

Why should I be using testing frameworks in PHP?

ε祈祈猫儿з 提交于 2019-12-04 15:31:31
I have recently heard a lot of people argue about using PHP testing features like PHPunit and SimpleTest together with their IDE of choice (Eclipse for me). After googling the subject, I have still a hard time understanding the pros and cons of using these testing frameworks to speed up development. If anyone could explain this for me in a more basic level, I would really appreciate it. I am using PHP5 for the notice. Thanks a lot! I'm not a big fan of unit testing: I'm not saying they're useless, they can be very useful - in certain situations. The thing is that some people tend to

CodeIgniter and SimpleTest — How to make my first test?

半城伤御伤魂 提交于 2019-12-04 14:49:30
I'm used to web development using LAMP, PHP5, MySQL plus NetBeans with Xdebug. Now I want to improve my development, by learning how to use (A) proper testing and (B) a framework. So I have set up CodeIgniter, SimpleTest and the easy Xdebug add-in for Firefox. This is great fun because maroonbytes provided me with clear instructions and a configured setup ready for download. I am standing on the shoulders of giants, and very grateful. I've used SimpleTest a bit in the past. Here is a the kind of thing I wrote: <?php require_once('../simpletest/unit_tester.php'); require_once('../simpletest

How to implement SimpleTest in Kohana

你。 提交于 2019-12-03 16:12:41
My boss assigned me to learn how to use Kohana and implement simple test in that. We would like to use it as our framework for future projects. Being new to both KohanaPHP and SimpleTest , I can't figure out how to do even the simplest test of my helpers. I can't even find a single step-by-step tutorial on how to attach SimpleTest to Kohana. Anyone here have an idea? We've created a SimpleTest_controller in Kohana and it gets the test from a directory tests define ( 'SIMPLE_TEST', '../tools/simpletest/'); require_once(SIMPLE_TEST . 'unit_tester.php'); require_once(SIMPLE_TEST . 'reporter.php')

which unit-test framework for PHP: simpletest, phpunit or? [closed]

两盒软妹~` 提交于 2019-12-03 11:40:49
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . I'm a big fan of simpletest because it's what I know. It has excellent support for mocking and web-testing. But I'm always scared of stagnating so any compelling arguments to switch would be appreciated. 回答1: I don't think either is going away anytime soon. Simpletest is

Mocking PHP functions in unit tests

☆樱花仙子☆ 提交于 2019-12-03 11:14:27
I'm unit-testing some PHP code with SimpleTest and I've run into trouble. In my tests of a database class I want to be able to set an expectation for PHPs mysql functions. In my tests of a wrapper class for the mail function I want to mock PHPs mail function. These are just some examples. The point is: I don't (always) want to test if my Mail class sends e-mail, I want to test how it calls the mail function. I want to be able to control what these functions return. I want to be able to test my Database class without needing a database, fixtures and that whole lot. I've got some experience with

Equivalent of SimpleTest “partial mocks” in PHPUnit?

删除回忆录丶 提交于 2019-12-03 09:31:10
I'm trying to migrate a bunch of tests from SimpleTest to PHPUnit and I was wondering if there is an equivalent for SimpleTest's partial mocks . Update: I can't seem to find anything in the docs which suggests that this feature is available, but it occurred to me that I could just use a subclass. Is this a good or bad idea? class StuffDoer { protected function doesLongRunningThing() { sleep(10); return "stuff"; } public function doStuff() { return $this->doesLongRunningThing(); } } class StuffDoerTest { protected function doesLongRunningThing() { return "test stuff"; } } class

How can I write tests for file upload in PHP?

有些话、适合烂在心里 提交于 2019-11-29 01:27:02
I'm using simpleTest to write my PHP tests. I'm writing a file upload plugin and was wondering how I may be testing it. I would like to check that the file is correctly uploaded, in the right folder, that error are correctly returned when needed, etc. How do I emulate a file upload (through the $_FILES variable) ? Are there any issues I should be aware of ? I've found an alternate solution. I've spoofed the $_FILES array with test data, created dummy test files in the tmp/ folder (the folder is irrelevant, but I tried to stick with the default). The problem was that is_uploaded_file and move

SimpleTest vs PHPunit

人走茶凉 提交于 2019-11-27 05:57:33
I was wondering if anyone that has experience in both this stuff can shed some light on the significant difference between the two if any? Any specific strength of each that makes it suitable for any specific case? edorian This question is quite dated but as it is still getting traffic and answers I though I state my point here again even so I already did it on some other (newer) questions. I'm really really baffled that SimpleTest still is considered an alternative to phpunit. Maybe i'm just misinformed but as far as I've seen: PHPUnit is the standard; most frameworks use it (like Zend