diff --git a/classes/forms.php b/classes/forms.php index f26b5f761..1a0f08efa 100644 --- a/classes/forms.php +++ b/classes/forms.php @@ -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 : []; } /** diff --git a/tests/test-entry-fields-collection.php b/tests/test-entry-fields-collection.php index 9cb32417f..ceed6dd6d 100644 --- a/tests/test-entry-fields-collection.php +++ b/tests/test-entry-fields-collection.php @@ -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() diff --git a/tests/test-forms-api.php b/tests/test-forms-api.php index 6734fef4e..ee4d9e3d5 100644 --- a/tests/test-forms-api.php +++ b/tests/test-forms-api.php @@ -1,18 +1,53 @@ 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' ); @@ -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 ) ); } /** @@ -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 ); @@ -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); @@ -156,4 +201,7 @@ public function testUpdateAndGet() $this->assertSame($looped, count($form['fields'])); } + + + } \ No newline at end of file diff --git a/tests/test-tests.php b/tests/test-tests.php index 672419e30..0db339508 100755 --- a/tests/test-tests.php +++ b/tests/test-tests.php @@ -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' ) ); } -} - +} \ No newline at end of file