PHP code example of i22 / functional-test-bundle

1. Go to this page and download the library: Download i22/functional-test-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

i22 / functional-test-bundle example snippets


  
   
  class AppKernel extends Kernel
  {
      public function registerBundles()
      {
          // ...
          if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
              // ...
              if ('test' === $this->getEnvironment()) {
                  $bundles[] = new I22\FunctionalTestBundle\I22FunctionalTestBundle();
              }
          }

          return $bundles;
      }
      
      // ...
  }
  

   
   
  return [
      // ...
      I22\FunctionalTestBundle\I22FunctionalTestBundle::class => ['test' => true],
  ];
  
  

  
  
  use I22\FunctionalTestBundle\Test\WebTestCase;
  
  class MyControllerTest extends WebTestCase
  {
      
  }
  

    
    
    use I22\FunctionalTestBundle\Test\WebTestCase;
    
    class MyControllerTest extends WebTestCase
    {
        protected function getFixtureFilePaths() : array
        {
            return [
                __DIR__.'/../../global-fixtures/users.yaml',                
            ];
        }
    }
  

      
      
      use I22\FunctionalTestBundle\Security\Authorization\UserAuthorizationTrait;
      use I22\FunctionalTestBundle\Test\WebTestCase;
      
      class MyControllerTest extends WebTestCase
      {
          use UserAuthorizationTrait;
          
          public function setUp()
              {
                  parent::setUp();
                  $user = $this->getDoctrine()->getRepository('App:User')->findOneBy(['email' => '[email protected]']);
                  $this->login($user);
              }
      }
  

  .
  └── tests/
      ├── ...
      └── Controller/
          └── MyControllerTest/
                ├── fixtures/
                ├   ├── users.yaml 
                ├   ├── ...
                └── MyControllerTest.php