0
votes

I don't see discussion forums over at phpunit.de so I'm hoping anyone using phpunit in this community can assist.

I downloaded the phpunit 6.4.3 phar and added it to my IDE. When I tried to extend the test class with PHPUnit_Framework_TestCase and use assertEquals, it throws this error:

"PHPUnit_Framework_TestCase cannot be resolved to a type"

The IDE wants to change TestCase to PHPUnit_Framework_MockObject_Matcher

So I let the IDE make the correction but there isn't an assertEquals method anymore (I checked just to be sure, by changing the phar, that assertEquals is in version 5.7.23 though).

Perhaps I'm overlooking the documentation, but when I Google PHPUnit_Framework_MockObject_Matcher, I'm seeing what the new method is.

Does anyone know to perform an equivalent assertEquals test in version 6.4.3?

=====

EDIT. Adding screenshots of my phpunit install, the project build path, and the Eclipse error.

install

build path

Eclipse

1
I recommend removing phar file completely, both from disk and settings and follow this tutorial instead mike42.me/blog/2015-08-continuous-testing-in-php-with-eclipse :)lchachurski
I followed the webpage. Same results as before. If I do this with PHPUnit 5.7 it works just fine. If my composer.json has "phpunit/phpunit": "6.3.*" (or 6.4), it does not work. It doesn't work because the line class ExampleTest extends PHPUnit_Framework_TestCase { throws "PHPUnit_Framework cannot be resolved to a type".MGoBlue93
Did you set PHP to 7+ in your IDE settings like suggested here? stackoverflow.com/questions/4589960/… I really want to help you solve this one :)lchachurski
Sorry for the late reply but I've been on travel. Yes, PHP 7.1 is set as the version. In fact, Eclipse resolves the version automagically when pointing to the php.exe. Thanks for your assistance -- I really appreciate your efforts on this!MGoBlue93

1 Answers

1
votes

It seems that your IDE doesn't support namespaces or has some trouble with it, check your settings. It's also possible you are using PHP 5.2 or lower which doesn't support namespaces. This underscore notation was used to identify the path to a class in old-school autoloading classes.

<?php
namespace Illuminate\Foundation\Testing;

use PHPUnit\Framework\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase {}

BTW. is it a composer project? If yes, it's recommended to download/install phpunit via composer.

composer require --dev phpunit/phpunit ^6.4