Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6556633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:58:11+00:00 2026-05-25T12:58:11+00:00

I have: PHP 5.3.8, PHPUnit 3.5.15, Netbeans 7.0.1 While using the standard example of

  • 0

I have: PHP 5.3.8, PHPUnit 3.5.15, Netbeans 7.0.1

While using the standard example of Netbeans for PHPUnit testing, it runs perfectly.
By adding just the “namespace test;” I get the error that Calculator.php is not a file nor a directory. How to solve this problem? (I would like to use the namespace declarative in my project)

THE CLASS TO TEST:

namespace test;

class Calculator {

/**
 * @assert (0, 0) == 0
 * @assert (0, 1) == 1
 * @assert (1, 0) == 1
 * @assert (1, 1) == 2
 * @assert (1, 2) == 4
 */
public function add($a, $b) {
    return $a + $b;
}

}

?>

THE UNIT TEST:

require_once dirname(__FILE__) . '/../Calculator.php';

/**
 * Test class for Calculator.
 * Generated by PHPUnit on 2011-09-11 at 00:52:24.
 */
class CalculatorTest extends PHPUnit_Framework_TestCase {

/**
 * @var Calculator
 */
protected $object;

/**
 * Sets up the fixture, for example, opens a network connection.
 * This method is called before a test is executed.
 */
protected function setUp() {
    $this->object = new Calculator;
}

/**
 * Tears down the fixture, for example, closes a network connection.
 * This method is called after a test is executed.
 */
protected function tearDown() {

}

/**
 * Generated from @assert (0, 0) == 0.
 */
public function testAdd() {
    $this->assertEquals(
            0, $this->object->add(0, 0)
    );
}

/**
 * Generated from @assert (0, 1) == 1.
 */
public function testAdd2() {
    $this->assertEquals(
            1, $this->object->add(0, 1)
    );
}

/**
 * Generated from @assert (1, 0) == 1.
 */
public function testAdd3() {
    $this->assertEquals(
            1, $this->object->add(1, 0)
    );
}

/**
 * Generated from @assert (1, 1) == 2.
 */
public function testAdd4() {
    $this->assertEquals(
            2, $this->object->add(1, 1)
    );
}

/**
 * Generated from @assert (1, 2) == 4.
 */
public function testAdd5() {
    $this->assertEquals(
            4, $this->object->add(1, 2)
    );
}

}

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:58:11+00:00Added an answer on May 25, 2026 at 12:58 pm

    Learn about using namespaced classes in your code. You need to create Calculator class instance not with:

    $this->object = new Calculator;
    

    but:

    $this->object = new \test\Calculator;
    

    I assume that class is loaded. If not see your autoloader or correct file path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example I use Netbeans for PHP and have started to integrate PHPUnit &
I have a very straightforward PHPUnit test in c:\kim\test\HelloTest.php on a Windows PC. I
How can I run a test within PHP instead of using the 'phpunit' command?
I have been using phpunit for a while, starting with 3.5.8, subsequently upgrading to
I'm writing unit tests for a project (written in PHP, using PHPUnit) that have
I have a strange bug. I launch a PHP Unit test Suite. At the
I used to have PHP websites and using url rewriting on picture to have
For example if I have a php script called RunAllTests.php in '/var/www/tests/RunAllTests.php' and I
I have a system with Jenkins, Ant, PHP, PHPunit among other php tools. Is
I have following, very simple, XML config for PHPUnit: <phpunit bootstrap=/_tests/TestAutoload.php> <testsuites> <testsuite name=Unit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.