Welcome Guest, Not a member yet? Register   Sign In
Testing CRUD operations
#10

Hi Codeigniter community
Is there anyone who can help me with Codeigniter4 and phpunit testing. I'm working on feature and unit testing of CRUD modules but there am facing issue that when when I run tests with debug option vendor/bin/phpunit --debug it does not show any output.
Code:
<?php

namespace App;

use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\ControllerTestTrait;
use CodeIgniter\Test\FeatureTestCase;
use CodeIgniter\Test\DatabaseTestTrait;
class JobsControllerTest extends FeatureTestCase
{
   use ControllerTestTrait,DatabaseTestTrait;
  
    /**
     * Test IndexPage
     */
  
    public function testIndexPage()
    {
      
        $result = $this->withUri('http://localhost/codeigniter4/institutes/jobs')
        ->controller(\App\Controllers\JobsController::class)
        ->execute('Index');
        // Check if success
        $this->assertTrue($result->isOK());
        // Check if redirect
        $this->assertFalse($result->isRedirect());
        // check the content of page
        $this->assertFalse($result->see('job'));
    }
    
    /**
     * Test Submit Job Data
     * is without form
     */
    function testSubmitJObData(){
        $body=[];
        $result = $this->withBody($body)
        ->controller(\App\Controllers\JobsController::class)
        ->execute('Index');
        // Check if success i
        $this->assertTrue($result->isOK());
        // Check if redirect
        $this->assertFalse($result->isRedirect());
        // check the content of page
        $this->assertFalse($result->see('Add'));
    }
    /**
     * Test Delete Job
     */
    public function testDeleteJobData()
    {
        $_POST['id']=3;
        $controller = new \App\Controllers\JobsController;
        $result=$controller->deleteRowData();
        $this->assertTrue($result);
    }
    
}
there is an issue with firt test. if I comment first one Second one runs successfully.
Reply


Messages In This Thread
Testing CRUD operations - by Poetawd - 10-30-2019, 06:35 PM
RE: Testing CRUD operations - by kilishan - 10-30-2019, 07:36 PM
RE: Testing CRUD operations - by Poetawd - 10-30-2019, 07:51 PM
RE: Testing CRUD operations - by kilishan - 10-30-2019, 08:16 PM
RE: Testing CRUD operations - by Poetawd - 10-30-2019, 08:35 PM
RE: Testing CRUD operations - by kilishan - 10-30-2019, 08:40 PM
RE: Testing CRUD operations - by Poetawd - 10-30-2019, 08:58 PM
RE: Testing CRUD operations - by kilishan - 10-31-2019, 06:27 AM
RE: Testing CRUD operations - by Poetawd - 10-31-2019, 01:58 PM
RE: Testing CRUD operations - by asadali - 01-14-2022, 03:59 AM
RE: Testing CRUD operations - by kenjis - 01-14-2022, 04:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB