phpunit

modelsManager not set in Phalcon Unittest

旧城冷巷雨未停 提交于 2019-12-12 04:18:35
问题 I'm integrating PHPUnit in my Phalcon project. I had it running correctly in MAMP, but when I run phpunit on my server, I keep getting some errors. This is UnitTestCase: <?php use \Phalcon\Di; use \Phalcon\DI\FactoryDefault; use \Phalcon\Test\UnitTestCase as PhalconTestCase; use \Phalcon\Mvc\View; use \Phalcon\Crypt; use \Phalcon\Mvc\Dispatcher; use \Phalcon\Mvc\Dispatcher as PhDispatcher; use \Phalcon\Mvc\Url as UrlResolver; use \Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; use \Phalcon\Mvc

mysqli_query(): Couldn't fetch mysqli while testing a PHP function in PHPUnit

…衆ロ難τιáo~ 提交于 2019-12-12 04:18:30
问题 I'm trying to write a PHPUnit test function on the school project I'm working on. The functions work fine with the normal web site. But when I try to test database related operations with PHPUnit, I keep getting mysqli_query(): Couldn't fetch mysqli . Here is the a sample code snippet: PHPUnit File: test.php function testFindById() { $expected_object = "Artist"; $result = Artist::find_by_id($id); $result_type = gettype($result); $this->assertEquals($expected_object, $result_type); }

Phpunit Code Coverage - 0 Files Analysed when including File with Function in it in Test

放肆的年华 提交于 2019-12-12 03:54:29
问题 I am getting a weird result when trying to create a code coverage report of my test. I call this: phpunit --coverage-html report tests/JSONTest.php And get this: PHPUnit 3.6.12 by Sebastian Bergmann. . Time: 0 seconds, Memory: 6.75Mb OK (1 test, 1 assertion) Generating code coverage report in HTML format ... done My test looks like this: <?php require_once dirname(__FILE__) . "/../include/includeAllNecessaryFiles.php"; class JSONTest extends PHPUnit_Framework_TestCase { public function

How do I use PHPUnit with CodeIgniter 3

浪子不回头ぞ 提交于 2019-12-12 03:16:41
问题 I have unsuccessfully tried to use PHPUnit 4.4.2 with CodeIgniter 3 . CodeIgniter 3 is the branch under active development and it support phpunit i don't know what is wrong with my code here . <?php // post_test.php class Post_test extends CI_TestCase { private $ci_obj; public function setUp() { $loader = $this->ci_core_class('loader'); $this->load = new $loader(); $this->ci_obj = $this->ci_instance(); $this->ci_set_core_class('model', 'CI_Model'); $test = $this->ci_vfs_clone('application

PHPUnit + CodeIgniter multiple objects with same name

依然范特西╮ 提交于 2019-12-12 03:15:56
问题 I currently test my CodeIgniter app with phpunit by using CIUnit (https://bitbucket.org/kenjis/my-ciunit). The problem is that I have multiple controllers with the same name. I have a controller in the root controller directory named "Blog" and I have a controller called "Blog" in the controller/ajax/ directory. The reason is to seperate all ajax requests from the main controller. When I am running tests on both files, I get the following error: PHP Fatal error: Cannot redeclare class Blog in

phpunit throwing exception when doesn't find file with name of testsuite

扶醉桌前 提交于 2019-12-12 03:13:51
问题 I was following Jon´s screencast about Unit Testing with PhpUnit and ZF when I got the exact same error that ratzip described in this question. As he commented, I also had the same problem even after creating tests as suggested here: for some reason, there was some script looking for a file named as I named my test suite (MyApp.php or whatever...). I looked around but wasn´t able to find where I should create this file and what it should contains. But, in a given moment, after had read this

How to create unit test for the function “beforeControllerAction” extended from yii framework

百般思念 提交于 2019-12-12 02:57:16
问题 I need some idea, to create unit test for the action 'beforeControllerAction', which is extended from yii framework. 回答1: beforeControllerAction is parent method from any 'mycontroller' app controller, coming from framework core. You don't need to test specific core framework code (is already tested). You need to test your own code. One way to test your controller is to extend/inherit your own 'mycontroller' controller first and build a test for it. Taken from this excellent article: Create

Laravel 5.2 PHPUnit assertViewHasAll() Failed

≯℡__Kan透↙ 提交于 2019-12-12 02:16:54
问题 Hi I have this unit test public function test_index_coupon(){ $coupons = factory(App\Models\Coupon::class, 5)->create(); $this->visit('/admin/coupons') ->assertResponseOk() ->assertViewHasAll('coupons'); } Here is my controller to list index of coupons public function index() { $coupons = Coupon::all(); return view('backend.admin.coupons.index', compact('coupons')); } And I can successfully list coupons with @foreach($coupons as $coupon) ..... @endforeach In my view, I check it via browser.

How do I create a functional test which includes a POST to a page with parameters?

自古美人都是妖i 提交于 2019-12-12 02:13:16
问题 I've read the documentation from Symfony2 but it doesn't seem to work. Here's my functional test: public function testSearch() { $client = static::createClient(); $crawler = $client->request('POST', '/search/results', array('term' => 'Carteron')); $this->assertTrue($crawler->filter('html:contains("Carteron")')->count() > 0); $this->assertTrue($crawler->filter('html:contains("Auctions")')->count() > 0); } In my controller the "term" parameter is null when this request comes in. However, search

selenium webdriver: mouseOver and PHPUnit

做~自己de王妃 提交于 2019-12-12 02:12:28
问题 How can I use action mouseOver() with PHPUnit in my tests? I can't find information about it.. Only using of java class Action. 回答1: Unfortunately the Selenium 2 WebDriver is not supported by the existing Selenium extension for PHPUnit (only the deprecated Selenium RC is). Refer to thread Selenium 2 (WebDriver) and Phpunit?, it's from a year ago but still valid. Check this post out for alternatives. 来源: https://stackoverflow.com/questions/8384087/selenium-webdriver-mouseover-and-phpunit