Skip to content
Snippets Groups Projects
Select Git revision
  • 782127d8bcfee5bdbb04f293158ce9f09d593aea
  • master default protected
  • fix/deprecated_functions
  • devel
  • feat/translations
  • feat/upgrade_to_pro_url
  • feat/lang
  • bugfix/require-interface
  • bugfix/require-once-error
  • feature/activation-hooks
  • feature/template-loader
  • feature/template-renderer
  • feature/plugin-activation
  • feature/hookable-object
  • feature/builder-pattern
  • 2.1.2
  • 2.1.1
  • 2.1.0
  • 2.0.0
  • 2.0.0-beta1
  • 1.4.4
  • 1.4.3
  • 1.4.2
  • 1.4.1
  • 1.4
  • 1.3.3
  • 1.3.2
  • 1.3.1
  • 1.3.0
  • 1.2.0
  • 1.1
  • 1.0
32 results

LegacyBuildDirector.php

Blame
  • TestForm.php 1.41 KiB
    <?php
    
    namespace Tests;
    
    use WPDesk\Forms\AbstractForm;
    
    class TestForm extends \PHPUnit\Framework\TestCase
    {
    
    	const FORM1_ID                = 'test_form';
    	const FORM1_FORM_DATA         = [ 'test' => true ];
    	const FORM1_UPDATED_FORM_DATA = [ 'test666' => true ];
    
    	private $form;
    
    	protected function setUp(){
    		// Create a new instance from the Abstract Class
    		$this->form = $this->getMockBuilder( AbstractForm::class )
    		                   ->enableOriginalConstructor()
    		                   ->setMethods(['get_form_id'])
    		                   ->getMockForAbstractClass();
    		$this->form->method( 'get_form_id' )->willReturn( self::FORM1_ID );
    		$this->form->method( 'create_form_data' )->willReturn( self::FORM1_FORM_DATA );
    	}
    
    	protected function getForm(){
    		return clone $this->form;
    	}
    
        /**
         * Test getting form id.
         */
        public function testFormId()
        {
        	$form = $this->getForm();
    	    $this->assertEquals(self::FORM1_ID, $form->get_form_id());
        }
    
    	/**
    	 * Test getting form data.
    	 */
    	public function testFormData()
    	{
    		$form = $this->getForm();
    		$this->assertSame( self::FORM1_FORM_DATA, $form->get_form_data());
    	}
    
    	/**
    	 * Test updated form data.
    	 */
    	public function testUpdatedFormData()
    	{
    		$form = $this->getForm();
    
    		$form->update_form_data( self::FORM1_UPDATED_FORM_DATA );
    		$this->assertSame( array_merge( self::FORM1_FORM_DATA, self::FORM1_UPDATED_FORM_DATA ), $form->get_form_data());
    	}
    }