Welcome Guest, Not a member yet? Register   Sign In
ci-phpunit-test for CodeIgniter 3.0
#81

(04-22-2017, 05:05 PM)kenjis Wrote: I've just released v0.15.0!

See https://github.com/kenjis/ci-phpunit-test/releases

Hi Kenjis

I installed your latest and phpunit seemed to hang with nothing happening
I tried the Welcome_test.php

The dump screen as follows:
==begin ==
dbu@d02dev:/var/www/r.dm.net/application/tests$ ../../vendor/bin/phpunit controllers/Welcome_test.php

PHPUnit 4.8.35 by Sebastian Bergmann and contributors.

(BLANK SPACE ) 
==end===


I used CI 3.1.4 and phpunit 4.8.35 /4.7.7 (none of them working! )

I wonder if I do missed anything

Many thanks
Reply
#82

(06-06-2017, 03:52 PM)ciadvantage Wrote: Hi Kenjis

I installed your latest and phpunit seemed to hang with nothing happening
I tried the Welcome_test.php

The dump screen as follows:
==begin ==
dbu@d02dev:/var/www/r.dm.net/application/tests$ ../../vendor/bin/phpunit controllers/Welcome_test.php

PHPUnit 4.8.35 by Sebastian Bergmann and contributors.

(BLANK SPACE ) 
==end===


I used CI 3.1.4 and phpunit 4.8.35 /4.7.7 (none of them working! )

I wonder if I do missed anything

Many thanks

You just misunderstand where you are.
You are in `application/tests`. So `Welcome_test.php` is located in `../controllers/Welcome_test.php`.
Reply
#83

Hi
How I can integrate Codeigniter 3 (CI3) sessions to ci-phpunit-test (CIPUT), because now CIPUT and CI3 have different sessions (header page code 307 for all pages)

I need test CI3 via CIPUT as registered user with same sessions.

Is it possible ?
Reply
#84

See https://github.com/kenjis/ci-app-for-ci-...s_test.php
for tests with sessions.
Reply
#85

Hello everyone,

I'm trying to test GroceryCRUD pages with ci-phpunit-test, but I have strange result.

PHP Code:
class Examples_test extends TestCase
{
    public function 
test_index()
    {
            
// Test OK
        
$this->request('GET''examples/customers_management');
        
$this->assertResponseCode(200);
        
        
// Test ~= NOK
        
$this->ajaxRequest('POST''examples/customers_management/ajax_list', [
            
'page' => 1,
            
'per_page' => 10,
            
'oder_by' => ['contactLastName''asc'],
            
'search_field' => ['contactLastName'],
            
'search_text' => ['ben'],
        ]);
        
$this->assertResponseCode(200);
    }



When I use ajaxRequest, I doesn't show assertion result. I show the ajax result in my console.

Any idea ?

Thanks

PS: thank you so much kenjis and John, Your libraries are fantastic. I use them every job day.
Reply
#86

> When I use ajaxRequest, I doesn't show assertion result. I show the ajax result in my console.

It is strange, because the only difference between `ajaxRequest` and `request` is just
to add `$_SERVER['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest'` or not.
Reply
#87

Hi, there!

ci-phpunit-test v0.16.0 has just released!
https://github.com/kenjis/ci-phpunit-test/releases

There are a few BC breaks. Please read Upgrade Note in the release note.
Reply
#88

Hi,

I've just released ci-phpunit-test v0.16.1.
It is a bug fix release.

https://github.com/kenjis/ci-phpunit-test/releases
Reply
#89
Star 

(04-22-2018, 05:42 AM)kenjis Wrote: Hi,

I've just released ci-phpunit-test v0.16.1.
It is a bug fix release.

https://github.com/kenjis/ci-phpunit-test/releases

Hi Kenjis,

I am facing the issue of NO TestCase class found. 

What I have done:

1. Installed Codeigniter 3.1.9
2. Unzipped and placed Application/tests from ci-phpunit-test-0.16.1 to my application folder.

Created Hello.php inside application/controllers as follows :


PHP Code:
<?php
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class Hello {
    public function get_hello()
    {
        $this->load->view('Hello_view'); 
    
}


Created Hello_test.php inside application/tests/controllers as follows:


PHP Code:
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class Hello_test extends TestCase{
    public function test_get_hello() {
        $output $this->request('GET',['Hello','get_hello']);
        $expected '<h2>Hello!</h2>';
        
        $this
->assertContains($expected,$output);
    }


Folder structure as follows:
   

From netbeans used Alt+F6 for test as well as tried from terminal by going into application/tests and using phpunit command.
Getting below output 

"C:\xampp\php\php.exe" "C:\xampp\php\phpunit" "--colors" "--log-json" "C:\Users\SOUMYA~1\AppData\Local\Temp\nb-phpunit-log.json" "C:\Program Files\NetBeans 8.2\php\phpunit\NetBeansSuite.php" "--" "--run=C:\xampp\htdocs\SAMPLE_PHPUNIT\application\tests"


Code:
An uncaught Exception was encountered

Type:        Error
Message:     Call to undefined function PhpParser\canonicalize()
Filename:    C:\xampp\htdocs\SAMPLE_PHPUNIT\application\tests\vendor\nikic\php-parser\test\PhpParser\CodeTestAbstract.php
Line Number: 17

Backtrace:
File: C:\xampp\htdocs\SAMPLE_PHPUNIT\application\tests\vendor\nikic\php-parser\test\PhpParser\CodeParsingTest.php
Line: 60
Function: getTests

File: C:\xampp\php\pear\PHPUnit\Util\Test.php
Line: 263
Function: invoke

File: C:\xampp\php\pear\PHPUnit\Framework\TestSuite.php
Line: 480
Function: getProvidedData

File: C:\xampp\php\pear\PHPUnit\Framework\TestSuite.php
Line: 834
Function: createTest

File: C:\xampp\php\pear\PHPUnit\Framework\TestSuite.php
Line: 212
Function: addTestMethod

File: C:\xampp\php\pear\PHPUnit\Framework\TestSuite.php
Line: 315
Function: __construct

File: C:\xampp\php\pear\PHPUnit\Framework\TestSuite.php
Line: 389
Function: addTestSuite

File: C:\Program Files\NetBeans 8.2\php\phpunit\NetBeansSuite.php
Line: 85
Function: addTestFile

File: C:\xampp\php\pear\PHPUnit\Runner\BaseTestRunner.php
Line: 124
Function: invoke

File: C:\xampp\php\pear\PHPUnit\TextUI\Command.php
Line: 149
Function: getTest

File: C:\xampp\php\pear\PHPUnit\TextUI\Command.php
Line: 129
Function: run

File: C:\xampp\php\phpunit
Line: 46
Function: main


Done.

Kindly help me what am I missing. 

Thank you
Reply
#90

@soumyaranjanr

It seems you run tests in PhpParser.
And it is better you don't use PHPUnit in XAMPP.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB