Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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,921 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

856 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