Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » PHPUnit not working (thus far) on Oxygen.1(PHPUnit not working (thus far) on Oxygen.1)
PHPUnit not working (thus far) on Oxygen.1 [message #1774793] Thu, 19 October 2017 15:53 Go to next message
Adam Sandler is currently offline Adam SandlerFriend
Messages: 4
Registered: July 2009
Junior Member
Hello:

I just downloaded and started running Oxygen.1.

I also installed Composer and PHPUnit in accordance with Chapter 1, the Windows section, from the documentation:

https://phpunit.de/manual/current/en/phpunit-book.pdf

Back in Eclipse I went to In Eclipse install the packages from http://download.eclipse.org/tools/pdt/updates/latest and installed the "PHP Development Tools" (Note: Under "PHP Development Tools (SDK), "PHP Development Tools (PDT) JUnit Tests" showed up in the "Will not be installed" part of the Solution Details section).

So I went into Project -> Properties -> PHP -> Source Paths -> Include Path -> Libraries,

I clicked Add External PHARs... and pointed the file chooser to the home of where I put PHPUnit, c:\php\latest\phpunit\phpunit.phar.

After that, in the Project Explorer tabbed pane, in the PHP Include Path node of the project tree, I can expand phpunit.phar and see all the packages underneath...

Here's the source code:

CalculatorTest.php

<?php
require 'Calculator.php';

class TestCalculator extends PHPUnit_Framework_TestCase {
    
    private $calculator;
    
    protected function setUp() {
        $this->calculator = new Calculator();
    }
    
    protected function tearDown() {
        $this->calculator = NULL;
    }
    
    public function testAdd() {
        $result = $this->calculator->add(1, 2);
        $this->assertEquals(4, $result);
    }
    
}


Calculator.php

<?php
class Calculator
{
    
    public function add($x, $y)
    {
       return $x + $y;
    }
    
}


For this line in the code:

class TestCalculator extends PHPUnit_Framework_TestCase { 


Eclipse has an error, "Quote:
PHPUnit_Framework_TestCase cannot be resolved to a type
".

Eclipse tells me to change it to PHPUnit_Framework_MockObject_Matcher instead... so I do so...

But when going to Run -> Run As _> PHPUnit Test, this popup is displayed:

"Quote:
Unable to find PHPUnit phar Check PHPUnit configuration
".

Does anyone have any ideas how to get PHPUnit running in Oxygen.1? I've attached a couple of screenshots showing my Eclipse. Suggestions are greatly appreciated. Thanks!
  • Attachment: pic3.jpg
    (Size: 199.56KB, Downloaded 642 times)
  • Attachment: pic4.jpg
    (Size: 319.79KB, Downloaded 518 times)
Re: PHPUnit not working (thus far) on Oxygen.1 [message #1778597 is a reply to message #1774793] Mon, 18 December 2017 11:56 Go to previous messageGo to next message
Eli Coten is currently offline Eli CotenFriend
Messages: 8
Registered: August 2015
Junior Member
It sounds like Eclipse is having trouble finding your PHPUnit PHAR. (This is a separate problem to the one where Eclipse complains that "PHPUnit_Framework_TestCase cannot be resolved to a type". This error has something to do with your include path but won't stop you from running the tests; if I were you I'd revert back to using PHPUnit_Framework_TestCase as PHPUnit_Framework_MockObject_Matcher is not a suitable replacement).

To resolve the error you're seeing you need to go to Window -> Preferences -> PHP -> Tools -> PHPUnit and set the PHPUnit Phar setting to the location of your PHPUnit phar.

Note that the Window -> Preferences might be under a different menu on different platforms, this is the location on Linux.
Re: PHPUnit not working (thus far) on Oxygen.1 [message #1783781 is a reply to message #1774793] Sat, 17 March 2018 01:58 Go to previous messageGo to next message
Meng Hua Che is currently offline Meng Hua CheFriend
Messages: 1
Registered: March 2018
Junior Member
May be you can try as this :

1. Going into Project > Properties
2. Under PHP Include Path, pick the "Libaries" tab.
3. Add an "external folder" with the path to where your framework is located.

M.H.
Re: PHPUnit not working (thus far) on Oxygen.1 [message #1783877 is a reply to message #1783781] Mon, 19 March 2018 19:18 Go to previous messageGo to next message
Adam Sandler is currently offline Adam SandlerFriend
Messages: 4
Registered: July 2009
Junior Member
@Meng Hua Che

> 1. Going into Project > Properties
> 2. Under PHP Include Path, pick the "Libaries" [sic] tab.

In the original post, I wrote this:

"So I went into Project -> Properties -> PHP -> Source Paths -> Include Path -> Libraries"

> Add an "external folder" with the path to where your
> framework is located.

In the original post,m I wrote this too...

I clicked Add External PHARs... and pointed the file chooser to the home of where I put PHPUnit, c:\php\latest\phpunit\phpunit.phar
Re: PHPUnit not working (thus far) on Oxygen.1 [message #1784014 is a reply to message #1783877] Wed, 21 March 2018 14:38 Go to previous messageGo to next message
Dawid Pakula is currently offline Dawid PakulaFriend
Messages: 290
Registered: March 2013
Senior Member
Try PDT 5.3 (Oxygen.3 released today). We improved PHPUnit support a lot.

Re: PHPUnit not working (thus far) on Oxygen.1 [message #1784962 is a reply to message #1784014] Fri, 06 April 2018 10:37 Go to previous messageGo to next message
Dimitri SMITH is currently offline Dimitri SMITHFriend
Messages: 1
Registered: April 2018
Junior Member
Hi,
I've got the same problem with the last version of Eclipse Oxygen 3
Re: PHPUnit not working (thus far) on Oxygen.1 [message #1784972 is a reply to message #1784962] Fri, 06 April 2018 12:08 Go to previous messageGo to next message
Dawid Pakula is currently offline Dawid PakulaFriend
Messages: 290
Registered: March 2013
Senior Member
Which one? "Unresolved Type" ? Make sure you have phpunit in your project build path. If you are using composer, PDT can take care of it.

Re: PHPUnit not working (thus far) on Oxygen.1 [message #1816422 is a reply to message #1784962] Tue, 29 October 2019 10:10 Go to previous message
Frank Royall is currently offline Frank RoyallFriend
Messages: 1
Registered: October 2019
Junior Member
Dimitri SMITH wrote on Fri, 06 April 2018 10:37
Hi,
I've got the same problem with the last version of Eclipse Oxygen 3

It seems, it's a coomon problem for the last version of Eclipse Oxygen 3, because I hear about it on this page not at first time. I agree with Dawid - it' s about "Unresolved type" and you should care about PHPunit in the project path.
Previous Topic: Eclipse PDT IIS 7 and xdebug!!!!!
Next Topic:Is PDT Built in Eclipse IDE for Web and JavaScript Developers?
Goto Forum:
  


Current Time: Sat Oct 05 16:35:31 GMT 2024

Powered by FUDForum. Page generated in 0.04648 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top