CFDBIntegrationWRContactFormTest

The Contact Form DB CFDBIntegrationWRContactFormTest class.

Defined (1)

The class is defined in the following location(s).

/phpunit/CFDBIntegrationWRContactFormTest.php  
  1. class CFDBIntegrationWRContactFormTest extends PHPUnit_Framework_TestCase { 
  2.  
  3. public function testSubmission() { 
  4. $dataForms = file_get_contents('CFDBIntegrationWRContactFormTest/dataForms.dat'); 
  5. $postID = 'i:645;'; 
  6. $post = file_get_contents('CFDBIntegrationWRContactFormTest/post.dat'); 
  7. $submissionsData = file_get_contents('CFDBIntegrationWRContactFormTest/submissionsData.dat'); 
  8. $dataContentEmail = file_get_contents('CFDBIntegrationWRContactFormTest/dataContentEmail.dat'); 
  9. $nameFileByIdentifier = file_get_contents('CFDBIntegrationWRContactFormTest/nameFileByIdentifier.dat'); 
  10. $requiredField = file_get_contents('CFDBIntegrationWRContactFormTest/requiredField.dat'); 
  11. $fileAttach = 'N;'; 
  12.  
  13. $dataForms = unserialize($dataForms); 
  14. $postID = unserialize($postID); 
  15. $post = unserialize($post); 
  16. $submissionsData = unserialize($submissionsData); 
  17. $dataContentEmail = unserialize($dataContentEmail); 
  18. $nameFileByIdentifier = unserialize($nameFileByIdentifier); 
  19. $requiredField = unserialize($requiredField); 
  20. $fileAttach = unserialize($fileAttach); 
  21.  
  22. $wr = new CFDBIntegrationWRContactForm(null); 
  23. $data = $wr->convertData($dataForms, $postID, $post, $submissionsData, $dataContentEmail,  
  24. $nameFileByIdentifier, $requiredField, $fileAttach); 
  25.  
  26. $this->assertEquals("Title_$postID", $data->title); 
  27. $this->assertEquals('hi there', $data->posted_data['my single line']); 
  28. $this->assertEquals('second line', $data->posted_data['my next single line']); 
  29. $this->assertEquals('Mr Michael D Simpson', $data->posted_data['my name']); 
  30. $this->assertEquals("123 Main Street, line2, Washington, DC 12345 United States", $data->posted_data['My Address']); 
  31. $this->assertEquals('345', $data->posted_data['My Number']); 
  32. $this->assertEquals('Checkbox 1 Checkbox 2', $data->posted_data['My Checkboxes']); 
  33. $this->assertEquals('Choice 1', $data->posted_data['My Radio Buttons']); 
  34. $this->assertEquals('Value 3', $data->posted_data['My List']); 
  35. $this->assertEquals('info@cfdbplugin.com', $data->posted_data['My Email']); 
  36. $this->assertEquals('http://cfdbplugin.com', $data->posted_data['Website']); 
  37. $this->assertEquals('1234567890', $data->posted_data['Phone']); 
  38. $this->assertEquals('Value 3', $data->posted_data['Dropdown']); 
  39. $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']); 
  40. $this->assertEquals('N/A', $data->posted_data['File Upload']); 
  41. $this->assertEquals('01/19/2015', $data->posted_data['Date/Time']); 
  42. $this->assertEquals('45, 09', $data->posted_data['Currency']); 
  43. $this->assertEquals("Line1\nLine2\nLine3", $data->posted_data['Multi-line Input']); 
  44. $this->assertEquals('dogs: Good cats: Average frogs: Poor', $data->posted_data['My likes']); 
  45. $this->assertEquals('United States', $data->posted_data['My Country']); 
  46. $this->assertEquals('hello', $data->posted_data['My Password']); 
  47.  
  48.  
  49. public function dataProviderFileUrl() { 
  50. $wpContentDirPath = dirname(dirname(dirname(dirname(__FILE__)))); 
  51. $data = array(); 
  52. $data[] = array('<a href="http://www.site.com/wp-content/uploads/2015/08/Amazon-icon1.png">Amazon.png</a>',  
  53. $wpContentDirPath . '/uploads/2015/08/Amazon-icon1.png'); 
  54. $data[] = array('<a href="http://www.site-something.com/wp-content/uploads/2015/06/twitter.png">Twitter.png</a>',  
  55. $wpContentDirPath . '/uploads/2015/06/twitter.png'); 
  56. $data[] = array('<a href="http://site.com/wp-content/uploads/wr_contactform/2015/01/icon-50x50.png">icon-50x50.png</a>',  
  57. $wpContentDirPath . '/uploads/wr_contactform/2015/01/icon-50x50.png'); 
  58. return $data; 
  59.  
  60. /** 
  61. * @dataProvider dataProviderFileUrl 
  62. */ 
  63. public function testParseFileUrl($fileUrl, $filePath) { 
  64. $wr = new CFDBIntegrationWRContactForm(null); 
  65. $this->assertEquals($filePath, $wr->parseFileUrl($fileUrl)); 
  66.