/lib/max/Delivery/tests/unit/querystring.del.test.php

https://bitbucket.org/valmy/openx · PHP · 106 lines · 54 code · 10 blank · 42 comment · 0 complexity · 4889c9293f715d48793c45a6af95ec48 MD5 · raw file

  1. <?php
  2. /*
  3. +---------------------------------------------------------------------------+
  4. | OpenX v2.8 |
  5. | ========== |
  6. | |
  7. | Copyright (c) 2003-2009 OpenX Limited |
  8. | For contact details, see: http://www.openx.org/ |
  9. | |
  10. | This program is free software; you can redistribute it and/or modify |
  11. | it under the terms of the GNU General Public License as published by |
  12. | the Free Software Foundation; either version 2 of the License, or |
  13. | (at your option) any later version. |
  14. | |
  15. | This program is distributed in the hope that it will be useful, |
  16. | but WITHOUT ANY WARRANTY; without even the implied warranty of |
  17. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
  18. | GNU General Public License for more details. |
  19. | |
  20. | You should have received a copy of the GNU General Public License |
  21. | along with this program; if not, write to the Free Software |
  22. | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
  23. +---------------------------------------------------------------------------+
  24. $Id$
  25. */
  26. require_once MAX_PATH . '/lib/max/Delivery/querystring.php';
  27. /**
  28. * A class for testing the ad.php functions.
  29. *
  30. * @package MaxDelivery
  31. * @subpackage TestSuite
  32. * @author
  33. *
  34. */
  35. class Test_DeliveryQuerystring extends UnitTestCase
  36. {
  37. /**
  38. * The constructor method.
  39. */
  40. function __construct()
  41. {
  42. $this->UnitTestCase();
  43. }
  44. /** TODO: test breaking on zoneid assert, chris to check function
  45. *
  46. * Populate variables from a specially encoded string. This is used because
  47. * in a click URL, a parameter could possibly be another URL.
  48. *
  49. * The resulting values are set into the $_GET, and $_REQUEST globals
  50. */
  51. function test_MAX_querystringConvertParams()
  52. {
  53. $tmpGet = $_GET;
  54. $tmpPost = $_POST;
  55. $tmpCookie = $_COOKIE;
  56. $tmpRequest = $_REQUEST;
  57. $zoneid = 123;
  58. $campaignid = 456;
  59. $bannerid = 789;
  60. $loc = "http://www.example.com/page.html?name1=value1&name2=value2";
  61. $referer = "http://www.example.com/referer.php?name3=value3&name4=value4";
  62. $dest = "http://www.example.com/landing.php?name5=value5&nam._e6=v.__[]alue6";
  63. $_COOKIE = array();
  64. $_GET = array();
  65. $_POST = array();
  66. $_REQUEST = array();
  67. $this->sendMessage('test_MAX_querystring');
  68. $_SERVER['QUERY_STRING'] = "zoneid={$zoneid}&campaignid={$campaignid}&bannerid={$bannerid}&loc=".urlencode($loc).'&referer='.urlencode($referer).'&maxdest=' . $dest;
  69. MAX_querystringConvertParams();
  70. $this->assertEqual($_GET['zoneid'], $zoneid);
  71. $this->assertEqual($_GET['campaignid'], $campaignid);
  72. $this->assertEqual($_GET['bannerid'], $bannerid);
  73. $this->assertEqual($_GET['loc'], $loc);
  74. $this->assertEqual($_GET['referer'], $referer);
  75. $this->assertEqual($_GET['oadest'], $dest);
  76. $_COOKIE = array();
  77. $_GET = array();
  78. $_POST = array();
  79. $_REQUEST = array();
  80. $this->sendMessage('test_MAX_querystring');
  81. $del = $GLOBALS['_MAX']['CONF']['delivery']['ctDelimiter'];
  82. $_SERVER['QUERY_STRING'] = 'oaparams='.strlen($del)."{$del}zoneid={$zoneid}{$del}campaignid={$campaignid}{$del}bannerid={$bannerid}{$del}loc=".urlencode($loc)."{$del}referer=".urlencode($referer)."{$del}oadest={$dest}";
  83. MAX_querystringConvertParams();
  84. $this->assertEqual($_GET['zoneid'], $zoneid);
  85. $this->assertEqual($_GET['campaignid'], $campaignid);
  86. $this->assertEqual($_GET['bannerid'], $bannerid);
  87. $this->assertEqual($_GET['loc'], $loc);
  88. $this->assertEqual($_GET['referer'], $referer);
  89. $this->assertEqual($_GET['oadest'], $dest);
  90. $_COOKIE = $tmpCookie;
  91. $_GET = $tmpGet;
  92. $_POST = $tmpPost;
  93. $_REQUEST = $tmpRequest;
  94. }
  95. }
  96. ?>