public function testSubmission() { $dataForms = file_get_contents('CFDBIntegrationWRContactFormTest/dataForms.dat'); $postID = 'i:645;'; $post = file_get_contents('CFDBIntegrationWRContactFormTest/post.dat'); $submissionsData = file_get_contents('CFDBIntegrationWRContactFormTest/submissionsData.dat'); $dataContentEmail = file_get_contents('CFDBIntegrationWRContactFormTest/dataContentEmail.dat'); $nameFileByIdentifier = file_get_contents('CFDBIntegrationWRContactFormTest/nameFileByIdentifier.dat'); $requiredField = file_get_contents('CFDBIntegrationWRContactFormTest/requiredField.dat'); $fileAttach = 'N;'; $dataForms = unserialize($dataForms); $postID = unserialize($postID); $post = unserialize($post); $submissionsData = unserialize($submissionsData); $dataContentEmail = unserialize($dataContentEmail); $nameFileByIdentifier = unserialize($nameFileByIdentifier); $requiredField = unserialize($requiredField); $fileAttach = unserialize($fileAttach); $wr = new CFDBIntegrationWRContactForm(null); $data = $wr->convertData($dataForms, $postID, $post, $submissionsData, $dataContentEmail, $nameFileByIdentifier, $requiredField, $fileAttach); $this->assertEquals("Title_{$postID}", $data->title); $this->assertEquals('hi there', $data->posted_data['my single line']); $this->assertEquals('second line', $data->posted_data['my next single line']); $this->assertEquals('Mr Michael D Simpson', $data->posted_data['my name']); $this->assertEquals("123 Main Street, line2, Washington, DC 12345 United States", $data->posted_data['My Address']); $this->assertEquals('345', $data->posted_data['My Number']); $this->assertEquals('Checkbox 1 Checkbox 2', $data->posted_data['My Checkboxes']); $this->assertEquals('Choice 1', $data->posted_data['My Radio Buttons']); $this->assertEquals('Value 3', $data->posted_data['My List']); $this->assertEquals('*****@*****.**', $data->posted_data['My Email']); $this->assertEquals('http://cfdbplugin.com', $data->posted_data['Website']); $this->assertEquals('1234567890', $data->posted_data['Phone']); $this->assertEquals('Value 3', $data->posted_data['Dropdown']); $this->assertEquals('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris fermentum odio sed ipsum fringilla ut tempor magna accumsan. Aliquam erat volutpat. Vestibulum euismod ipsum non risus dignissim hendrerit. Nam metus arcu, blandit in cursus nec, placerat vitae arcu. Maecenas ornare porta mi, et tincidunt nulla luctus non.”', $data->posted_data['Text']); $this->assertEquals('N/A', $data->posted_data['File Upload']); $this->assertEquals('01/19/2015', $data->posted_data['Date/Time']); $this->assertEquals('45,09', $data->posted_data['Currency']); $this->assertEquals("Line1\nLine2\nLine3", $data->posted_data['Multi-line Input']); $this->assertEquals('dogs: Good cats: Average frogs: Poor', $data->posted_data['My likes']); $this->assertEquals('United States', $data->posted_data['My Country']); $this->assertEquals('hello', $data->posted_data['My Password']); }
public function addActionsAndFilters() { // Admin notices add_action('admin_notices', array(&$this, 'addAdminNotices')); // Add the Admin Config page for this plugin // Add Config page as a top-level menu item on the Admin page add_action('admin_menu', array(&$this, 'createAdminMenu')); // Add Database Options page add_action('admin_menu', array(&$this, 'addSettingsSubMenuPage')); // Hook into Contact Form 7 when a form post is made to save the data to the DB if ($this->getOption('IntegrateWithCF7', 'true') == 'true') { require_once 'CFDBIntegrationContactForm7.php'; $integration = new CFDBIntegrationContactForm7($this); $integration->registerHooks(); } // Hook into Fast Secure Contact Form if ($this->getOption('IntegrateWithFSCF', 'true') == 'true') { require_once 'CFDBIntegrationFSCF.php'; $integration = new CFDBIntegrationFSCF($this); $integration->registerHooks(); } // Hook into JetPack Contact Form if ($this->getOption('IntegrateWithJetPackContactForm', 'true') == 'true') { require_once 'CFDBIntegrationJetPack.php'; $integration = new CFDBIntegrationJetPack($this); $integration->registerHooks(); } // Hook into Gravity Forms if ($this->getOption('IntegrateWithGravityForms', 'true') == 'true') { require_once 'CFDBIntegrationGravityForms.php'; $integration = new CFDBIntegrationGravityForms($this); $integration->registerHooks(); } // Hook to work with WR ContactForms if ($this->getOption('IntegrateWithWrContactForms', 'true') == 'true') { require_once 'CFDBIntegrationWRContactForm.php'; $integration = new CFDBIntegrationWRContactForm($this); $integration->registerHooks(); } // Hook to work with Quform if ($this->getOption('IntegrateWithQuform', 'true') == 'true') { require_once 'CFDBIntegrationQuform.php'; $integration = new CFDBIntegrationQuform($this); $integration->registerHooks(); } // Hook to work with Ninja Forms if ($this->getOption('IntegrateWithNinjaForms', 'true') == 'true') { require_once 'CFDBIntegrationNinjaForms.php'; $integration = new CFDBIntegrationNinjaForms($this); $integration->registerHooks(); } // Hook to work with Caldera Forms Forms if ($this->getOption('IntegrateWithCalderaForms', 'true') == 'true') { require_once 'CFDBIntegrationCalderaForms.php'; $integration = new CFDBIntegrationCalderaForms($this); $integration->registerHooks(); } // Enfold theme forms if ($this->getOption('IntegrateWithEnfoldThemForms', 'true') == 'true') { require_once 'CFDBIntegrationEnfoldTheme.php'; $enfold = new CFDBIntegrationEnfoldTheme($this); $enfold->registerHooks(); } // Have our own hook to receive form submissions independent of other plugins add_action('cfdb_submit', array(&$this, 'saveFormData')); // Register Export URL add_action('wp_ajax_nopriv_cfdb-export', array(&$this, 'ajaxExport')); add_action('wp_ajax_cfdb-export', array(&$this, 'ajaxExport')); // Register Get File URL add_action('wp_ajax_nopriv_cfdb-file', array(&$this, 'ajaxFile')); add_action('wp_ajax_cfdb-file', array(&$this, 'ajaxFile')); // Register Get Form Fields URL add_action('wp_ajax_nopriv_cfdb-getFormFields', array(&$this, 'ajaxGetFormFields')); add_action('wp_ajax_cfdb-getFormFields', array(&$this, 'ajaxGetFormFields')); // Register Validate submit_time value (used in short code builder page) add_action('wp_ajax_nopriv_cfdb-validate-submit_time', array(&$this, 'ajaxValidateSubmitTime')); add_action('wp_ajax_cfdb-validate-submit_time', array(&$this, 'ajaxValidateSubmitTime')); // Login via Ajax instead of login form add_action('wp_ajax_nopriv_cfdb-login', array(&$this, 'ajaxLogin')); add_action('wp_ajax_cfdb-login', array(&$this, 'ajaxLogin')); // Shortcode to add a table to a page $sc = new CFDBShortcodeTable(); $sc->register(array('cf7db-table', 'cfdb-table')); // cf7db-table is deprecated // Shortcode to add a DataTable $sc = new CFDBShortcodeDataTable(); $sc->register('cfdb-datatable'); // Shortcode to add a JSON to a page $sc = new CFDBShortcodeJson(); $sc->register('cfdb-json'); // Shortcode to add a value (just text) to a page $sc = new CFDBShortcodeValue(); $sc->register('cfdb-value'); // Shortcode to add entry count to a page $sc = new CFDBShortcodeCount(); $sc->register('cfdb-count'); // Shortcode to add values wrapped in user-defined html $sc = new CFDBShortcodeHtml(); $sc->register('cfdb-html'); // Shortcode to generate Export URLs $sc = new CFDBShortcodeExportUrl(); $sc->register('cfdb-export-link'); // Shortcode to save data from non-CF7/FSCF forms $sc = new CFDBShortCodeSavePostData(); $sc->register('cfdb-save-form-post'); // Shortcode to save data Form Maker submissions $sc = new CFDBShortCodeSaveFormMakerSubmission(); $sc->register('cfdb-save-form-maker-post'); }
/** * @dataProvider dataProviderFileUrl */ public function testParseFileUrl($fileUrl, $filePath) { $wr = new CFDBIntegrationWRContactForm(null); $this->assertEquals($filePath, $wr->parseFileUrl($fileUrl)); }