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
4,141 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
[X]
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
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

717 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