Skip to content

Commit

Permalink
Resolve conflicts #2766
Browse files Browse the repository at this point in the history
  • Loading branch information
New0 committed Nov 19, 2018
1 parent 0b0c94e commit 4d04990
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 21 deletions.
6 changes: 2 additions & 4 deletions classes/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,8 @@ protected static function get_stored_forms() {

}
}
if( ! is_array( self::$stored_forms ) ){
self::$stored_forms = [];
}
return self::$stored_forms;

return is_array(self::$stored_forms ) ? self::$stored_forms : [];
}

/**
Expand Down
1 change: 0 additions & 1 deletion tests/test-entry-fields-collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public function testSetThroughConstructor(){
*
* @since 1.7.0
*
*
* @covers Caldera_Forms_Entry_Fields::__construct()
* @covers Caldera_Forms_Entry_Fields::set_fields_form_array()
Expand Down
62 changes: 55 additions & 7 deletions tests/test-forms-api.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,53 @@
<?php


class MockFormAPI extends Caldera_Forms_Forms {
public static function get_stored_forms()
{
return parent::get_stored_forms(); // TODO: Change the autogenerated stub
}
}

class Test_Caldera_Forms_API extends Caldera_Forms_Test_Case
{

/**
public function setUp()
{
$forms = Caldera_Forms_Forms::get_forms(false,true );
if (! empty( $forms )) {
$ids = [];
foreach ( $forms as $form ) {
$ids[] = $form;
}
if( ! empty($ids)){
Caldera_Forms_DB_Form::get_instance()->delete($ids);
}
}
parent::setUp(); // TODO: Change the autogenerated stub
}

/**
* @since 1.8.0
*
* @covers Caldera_Forms_Forms::get_forms()
* @covers Caldera_Forms_Forms::get_stored_forms()
*/
public function testGetStoredForms(){
$forms = Caldera_Forms_Forms::get_forms(false,true );
$this->assertEmpty($forms);
$this->assertTrue( is_array($forms));

}
/**
* Compare the database abstraction to the forms API
*
* @since 1.7.0
**
*
* @covers Caldera_Forms_Forms::get_forms()
* @covers Caldera_Forms_Forms::get_stored_forms()
*/
public function testGetFormVsDbForm(){
$form_one_id = $this->import_autoresponder_form();
$form_one_id = $this->import_autoresponder_form();
$form_two_id = $this->import_contact_form();
$db_results = Caldera_Forms_DB_Form::get_instance()->get_all( true );
$db_ids = wp_list_pluck( $db_results, 'form_id' );
Expand All @@ -25,15 +60,15 @@ public function testGetFormVsDbForm(){


/**
* Make sure forms added on the caldera_forms_get_forms fitler work
* Make sure forms added on the caldera_forms_get_forms filter work
*
* @since 1.7.0
*
* covers caldera_forms_get_forms filter
* @covers caldera_forms_get_forms filter
* @covers Caldera_Forms_Forms::get_forms()
*/
public function testFilterAddedForms(){
$this->assertCount(3, Caldera_Forms_Forms::get_forms(false, false ) );
$this->assertCount(0, Caldera_Forms_Forms::get_forms(false, true ) );
}

/**
Expand All @@ -46,6 +81,10 @@ public function testFilterAddedForms(){
*/
public function testGetFormsNoDetails()
{
$forms = Caldera_Forms_Forms::get_forms(true,true );
$this->assertEmpty($forms);
$this->assertTrue( is_array($forms));

$form_one_id = $this->import_autoresponder_form();
$form_two_id = $this->import_contact_form();
$forms = Caldera_Forms_Forms::get_forms(false,true );
Expand Down Expand Up @@ -75,6 +114,12 @@ public function testGetFormsNoDetails()
*/
public function testGetFormsWithDetails()
{

//https://github.com/CalderaWP/Caldera-Forms/issues/2736#issuecomment-436678659
$forms = Caldera_Forms_Forms::get_forms(true,true );
$this->assertEmpty($forms);
$this->assertTrue( is_array($forms));

$form_one_id = $this->import_autoresponder_form();
$form_two_id = $this->import_contact_form();
$forms = Caldera_Forms_Forms::get_forms(true,true);
Expand Down Expand Up @@ -156,4 +201,7 @@ public function testUpdateAndGet()
$this->assertSame($looped, count($form['fields']));
}




}
15 changes: 6 additions & 9 deletions tests/test-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,22 @@ class TestsTest extends Caldera_Forms_Test_Case {
/**
* Make sure assertions work
*
* @group test
*/
function testAsserts() {
// replace this with some actual testing code
$this->assertTrue( true );
function testAsserts() {
// replace this with some actual testing code
$this->assertTrue( true );


}
}

/**
* Make sure we can read/write the DB
*
* @group test
*/
public function testDB(){
public function testDB(){
update_option( 'hi', 'roy' );
$this->assertSame( 'roy', get_option( 'hi' ) );
}
}

}

0 comments on commit 4d04990

Please sign in to comment.