CakeDC\Users\Test\TestCase\Controller\Traits\BaseTraitTest::setUp PHP Method

setUp() public method

SetUp and create Trait
public setUp ( ) : void
return void
    public function setUp()
    {
        parent::setUp();
        $traitMockMethods = array_unique(array_merge(['getUsersTable'], $this->traitMockMethods));
        $this->table = TableRegistry::get('CakeDC/Users.Users');
        try {
            $this->Trait = $this->getMockBuilder($this->traitClassName)->setMethods($traitMockMethods)->getMockForTrait();
            $this->Trait->expects($this->any())->method('getUsersTable')->will($this->returnValue($this->table));
        } catch (PHPUnit_Framework_MockObject_RuntimeException $ex) {
            debug($ex);
            $this->fail("Unit tests extending BaseTraitTest should declare the trait class name in the \$traitClassName variable before calling setUp()");
        }
        if ($this->mockDefaultEmail) {
            Email::configTransport('test', ['className' => 'Debug']);
            $this->configEmail = Email::config('default');
            Email::config('default', ['transport' => 'test', 'from' => '[email protected]']);
        }
    }

Usage Example

 /**
  * setup
  *
  * @return void
  */
 public function setUp()
 {
     $this->traitClassName = 'CakeDC\\Users\\Controller\\Traits\\UserValidationTrait';
     $this->traitMockMethods = ['dispatchEvent', 'isStopped', 'redirect', 'getUsersTable', 'set'];
     $this->mockDefaultEmail = true;
     parent::setUp();
 }
All Usage Examples Of CakeDC\Users\Test\TestCase\Controller\Traits\BaseTraitTest::setUp