mpsn Posted November 10, 2011 Share Posted November 10, 2011 Hi, I want to use SimpleTest framework (unit test library) to test if a web page has the text set in the title tag, but I am using localhost, so I think that's why it doesn't run, does anyone know how to configure php.ini (I think it's security issue) here is script: ========= <?php require_once('simpletest/autorun.php'); require_once('simpletest/web_tester.php'); class TestOfMyWebPage extends WebTestCase { //test home page is up and running function testMyPageIndex() {//THIS function just goes to the page then asserts if title tag has "My Page:Home" text set $this->get("C:/xampp/htdocs/projectMyWebsite/MyPageIndex.html"); $this->assertTitle("My Page:Home");//test if the page contains this page content } } ?> Any help much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/ Share on other sites More sharing options...
Adam Posted November 11, 2011 Share Posted November 11, 2011 What leads you to security and php.ini? Are you receiving any errors? Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287233 Share on other sites More sharing options...
xyph Posted November 11, 2011 Share Posted November 11, 2011 I think he may be missing a web server? Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287234 Share on other sites More sharing options...
Adam Posted November 11, 2011 Share Posted November 11, 2011 $this->get("C:/xampp/htdocs/projectMyWebsite/MyPageIndex.html"); Hmm.. I don't think so. Though how are you trying to run this exactly mx760? Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287235 Share on other sites More sharing options...
mpsn Posted November 11, 2011 Author Share Posted November 11, 2011 I use XAMPP (so I have Apache installed), but when I run this script from cmd, I get this message: Equal expectation fails at character 0 with [My Page:Home] and [bad requrest!] at [C:\xampp\htdocs\path\way\to\this\script for line 9] line 9 is my assertion: $this->assertTitle b/c I am pretty sure assertTitle checks the <title> tag If not too much trouble, if anyone just install simpletest and then copy my code but make up a simple webpage to run off your localhost (make sure put the simpletest dir in C:\xampp\htdocs along with your webpage of course) and test quickly for me what you get, that be great. Here is link on Web SimpleTest lesson: http://simpletest.org/en/web_tester_documentation.html Any help much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287236 Share on other sites More sharing options...
Adam Posted November 11, 2011 Share Posted November 11, 2011 What do you see if you go to "http://localhost" or more importantly "http://localhost/projectMyWebsite/MyPageIndex.html" in your browser? Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287243 Share on other sites More sharing options...
mpsn Posted November 11, 2011 Author Share Posted November 11, 2011 My website, I know it is not the localhost issue (as I said, XAMPP has Apache,MySQL and PHP all prebundled), and it is not SimpleTest b/c I have tried the same test on internet-based webpages like cnn.com etc, so that's why I figure it must be php.ini, if possible (it only takes 5 minutes or so), just install XAMPP or whatever used for localhost make a simple webpage that you store to C:\xampp\htdocs and install SimpleTest (put in C:\xampp\htdocs) and make make a new script (just copy my code but change info according to your webpage and directory) and put SimpleTest, your webpage, SimpleTest script for your webpage in htdocs and just run it. Sorry to be longwinded. Any help much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287253 Share on other sites More sharing options...
mpsn Posted November 12, 2011 Author Share Posted November 12, 2011 Hi, please can someone just help out! The installation is simple (download XAMPP, download SimpleTest, make a simple webpage, make a simple SimpleTest script and put the SimpleTest script, your webpage to test, SimpleTest dir inside htdocs!) Any help much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287548 Share on other sites More sharing options...
trq Posted November 12, 2011 Share Posted November 12, 2011 No one is going to install some framework just to test your code. You might want to actually describe the issue your having. Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287560 Share on other sites More sharing options...
mpsn Posted November 12, 2011 Author Share Posted November 12, 2011 Hi, this the error I get: Equal expectation fails at character 0 with [My Page:Home] and [bad requrest!] at [C:\xampp\htdocs\path\way\to\this\script for line 9] line 9 is my assertion: $this->assertTitle b/c I am pretty sure assertTitle checks the <title> tag Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287651 Share on other sites More sharing options...
mpsn Posted November 16, 2011 Author Share Posted November 16, 2011 Can someone help me with SimpleTest for HTML. I just want to test if a certain page has the text in it, but when I run this SimpleTest script for the page I'm testing (Index.html), it outputs this message: "Text [Hello world!.]" not detected in [string: Bad request! Bad request! Your browser (or proxy) sent a request that this server could not understand. Error 400]" Here is script Index.html: ================= <html> <head></head> <body <p>Hello world!</p> </body> </html> Here is SimpleTest script for testing Index.html: ================================= <?php require_once('simpletest/autorun.php'); require_once('simpletest/web_tester.php'); require_once('Index.html'); class TestOfIndex extends WebTestCase { function testHomeHasTheseLinks() { $this->get("localhost/dir/Index.html"); $this->assertText('Hello world!'); } } ?> Any help much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1288611 Share on other sites More sharing options...
trq Posted November 16, 2011 Share Posted November 16, 2011 Iv'e not used simpletest, but I would assume that get() expects a url. Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1288629 Share on other sites More sharing options...
mpsn Posted November 16, 2011 Author Share Posted November 16, 2011 No, that's not it, b/c when I try the following assertion on the get: $this->assertTrue($this->get("localhost/proj_ath/xmlShredderIndex.php")); it returns: PASS 1, FAIL 1 (the get passed, the assertText fails, I know b/c I commented out the assertText and I still get PASS 1) in the command line (this is just SimpleTest output) Any help much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1288634 Share on other sites More sharing options...
mpsn Posted November 16, 2011 Author Share Posted November 16, 2011 I beg anyone to please help a new php programmer out! I even tried contacting the creater of SimpleTest, he doesn't respond. Any help much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1288813 Share on other sites More sharing options...
mpsn Posted November 17, 2011 Author Share Posted November 17, 2011 :'( Please, please why won't people help out? I just want to get it to check if the desired webpage has the content via assertText, but it doesn' work when I run it. At first I thought it was local host but I tested that via: $this->assertTrue($this->get("localhost/projidr/Whatever.php")) I beg, I beg someone to help me!! Any help much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1288843 Share on other sites More sharing options...
trq Posted November 17, 2011 Share Posted November 17, 2011 Either you haven't provided enough information for anyone to be able to help, no one has enough knowledge with simpleTest or your desperation is turning people off wanting to assist you. Either way, constantly bumping your thread will get you nowhere. Quote Link to comment https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1288869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.