Solved

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in C:\wamp\www\phpvqp3_scripts\ch14\RectangleTest.php on line 8

Posted on 2014-03-21
3
3,685 Views
Last Modified: 2014-03-22
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>cd c:\wamp\www\phpvqp_scripts
The system cannot find the path specified.

C:\Windows\system32>cd c:\wamp\www\phpvqp_script
The system cannot find the path specified.

C:\Windows\system32>cd c:\wamp\www\phpvqp3_scripts

c:\wamp\www\phpvqp3_scripts>cd ch14

c:\wamp\www\phpvqp3_scripts\ch14>phpunit rectangletest
PHP Warning:  require_once(File/Iterator/Autoload.php): failed to open stream: N
o such file or directory in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Auto
load.php on line 64

Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No suc
h file or directory in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Autoload.
php on line 64
PHP Fatal error:  require_once(): Failed opening required 'File/Iterator/Autoloa
d.php' (include_path='.;C:\Program Files (x86)\NuSphere\PhpED\php54\..\include_l
ib') in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Autoload.php on line 64

Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php
' (include_path='.;C:\Program Files (x86)\NuSphere\PhpED\php54\..\include_lib')
in C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit\Autoload.php on line 64

c:\wamp\www\phpvqp3_scripts\ch14>

Open in new window



does spl need to be installed?




running rectangletest from browser
Fatal error: Class 'PHPUnit_Framework_TestCase' not found in C:\wamp\www\phpvqp3_scripts\ch14\RectangleTest.php on line 8


rectangle.php
<?php # Script 7.6 - Rectangle.php
/*  This page defines the Rectangle class.
 *  The class contains two attributes: width and height.
 *  The class contains five methods: 
 *  - __construct()
 *  - setSize()
 *  - getArea()
 *  - getPermeter()
 *  - isSquare()
 */
 
class Rectangle {
    
    // Use the debug trait:
    //use tDebug;

    // Declare the attributes:
    public $width = 0;
    public $height = 0;

    // Constructor:
    function __construct($w = 0, $h = 0) {
        $this->width = $w;
        $this->height = $h;
    }
    
    // Method to set the dimensions:
    function setSize($w = 0, $h = 0) {
        $this->width = $w;
        $this->height = $h;
    }
    
    // Method to calculate and return the area:
    function getArea() {
        return ($this->width * $this->height);
    }
    
    // Method to calculate and return the perimeter:
    function getPerimeter() {
        return ( ($this->width + $this->height) * 2 );
    }
    
    // Method to determine if the rectange 
    // is also a square.
    function isSquare() {   
        if ($this->width == $this->height) {
            return true; // Square
        } else {
            return false; // Not a square
        }
        
    }

} // End of Rectangle class.

Open in new window



rectangletest.php
<?php # RectangleTest.php - Script 14.3 #2
// This page defines the RectangleTest class.

// Need the Rectangle class in order to work:
require('Rectangle.php');

// Define the class:
class RectangleTest extends PHPUnit_Framework_TestCase {
    
    // For storing the Rectangle object:
    protected $r;
    
    // Create an object to use:
	function setUp() {
	    $this->r = new Rectangle(8,9);
	}

    // Test the getArea() method:
	function testGetArea() {
	    $this->assertEquals(72, $this->r->getArea());
	}
    
    // Test the getPerimeter() method:
    function testGetPerimeter() {
        $this->assertEquals(34, $this->r->getPerimeter());
    }

    // Test the isSquare() method:
    function testIsSquare() {
        
        // Should not be a square in this case!
        $this->assertFalse($this->r->isSquare());
        
        // Make it a square and test again:
        $this->r->setSize(5,5);
        $this->assertTrue($this->r->isSquare());

    }

    // Test the setSize() method:
    function testSetSize() {
        $w = 5;
        $h = 8;
        $this->r->setSize($w, $h);
        $this->assertEquals($w, $this->r->width);
        $this->assertEquals($h, $this->r->height);
    }
    
} // End of RectangleTest class.

Open in new window

0
Comment
Question by:rgb192
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
duncanb7 earned 500 total points
ID: 39946945
Probably it is caused  by the incorrect  file path, please take a look at $filepath that
whether is matched to your exact directory file path or not , and add the following code in your rectangletest.php that may  solve the issue and take care of "/" slash on your directory path

$filepath = realpath (dirname(__FILE__));
echo $filepath."====\n";
require($filepath.'/Rectangle.php');

Duncan
0
 

Author Closing Comment

by:rgb192
ID: 39948006
okay, you allowed me to see that this is a pear/phpunit error which was fixed with installation of pear/phpunit.
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 39948204
thanks for your pt

have a nice day

Duncan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now