Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/250900-web-simpletest-help/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287236
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287253
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287548
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1287651
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1288611
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1288634
Share on other sites

:'( 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!

Link to comment
https://forums.phpfreaks.com/topic/250900-web-simpletest-help/#findComment-1288843
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.