Mirza

Issue while Integrating PHPUnit into Processwire

Recommended Posts

Hi All,

I am trying to include the unit tests into our project which is in Processwire(I love it).

Directory structure for the same will be shown below

5a12ba75d3c46_ScreenShot2017-11-20at3_16_27PM.png.3408f9d16a8fd6e79d0be91105fb19a9.png

 

Here PWTestCase.php is the parent file where it is getting inherited from the PHPUNIT framework TestCase class and It is in same namespace ProcessWire; as shown below

5a12bb0a57bea_ScreenShot2017-11-20at3_22_22PM.png.55cafb147b34e9274de7458816e443a6.png

Now I have a basic unit test(FuncTest.php as shown below) to check the language calling the function getLanguage() residing in site/templates/_func.php.

5a12bc91352a4_ScreenShot2017-11-20at3_28_25PM.png.0cf8e46be976f0892c32f7c95c59983f.png

***when try to run this test, getting undefined function getLanguage as shown below***

5a12bcb83c126_ScreenShot2017-11-20at3_26_46PM.png.6fb724f6f8cff5d9addee399ee650c64.png

 

Since I am using namespace ProcessWire; & bootstraping processwire in PWTestCase why i am not able to access functions? Can you please suggest where i am going wrong?

Thanks in advance.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By chrizz
      I am currently developing a little application which is supposed to run on a raspberry. I decided to take advantage of PW's capabilities to deal with data not only in the sense of a common website but more as an application. 
      I wrote a lot of modules for this and I wrote tests for some of the methods (using PHPUnit). This works fine so far for methods which are independent from database (e.g. calculating an upcoming date/time by a given schedule). Now I am thinking of extending this by writing tests also for methods which rely on data from the database (e.g. it need to be checked if something exists on that given date/time). This information is currently stored as page in PW. 
      One of my thoughts: create necessary pages in PW for running the test and delete them afterwards. But somehow this just feels wrong. 
      Any kind of input how you would tackle this would be great!
      Thanks a lot! 
       
    • By FrancisChung
      I'm writing this to give back something to the community that has given so much up front over the past year.
      I noticed there's hardly any discussion about testing in these forums so I decided to write this quick primer to get some discussion going.
      I'm by no means an expert on phpunit or selenium but I had to jump through a few hoops to get it working (especially with PHPStorm), so I thought I figured I should share my experiences with the community. 

      Also, I'm hoping non Phpstorm users can still  pick something up useful in this post.

      Prerequisites : It is assumed Phpunit (https://phpunit.de/) is installed via Composer,   Selenium (http://www.seleniumhq.org/) and Php-webdriver for Selenium (https://github.com/facebook/php-webdriver) is preinstalled.
      For Phpstorm users, there's a fairly detailed installation and unit testing instructions here (https://www.jetbrains.com/help/phpstorm/2016.1/testing.html)
      I found some parts of it leaving me with unanswered questions, so I'm hoping this post will supplement any questions that you might encounter.

      Rather than writing a single monolithic post, I will write several posts covering different topics.
    • By FrancisChung
      Hi fellow Processwirers (?),
      I was wondering if anyone here uses PHPStorm in conjunction with PhpUnit?
      In particular, I'm trying to get it to work with Processwire so I can incorporate the Pages & other intrinsic Processwire objects into the testing.
      Any example or real life configuration examples would be most welcome.

      Thanks in advance.
    • By FvG
      Now that 2.3 has been finished, when will you (Ryan) start developing 2.4?
      According to the roadmap 2.4 will port the hole system to PHP 5.3+ which I think is great.
      It says we'll get namespaces, PSR-0 and PSR-1 support. What exactly does it mean? Will it use Composer? I really think it should as it's the greatest asset for the future of PHP. We could keep the framework seperate so that others can use it (http://processwire.com/talk/topic/818-currentformer-textpattern-users-what-do-you-think-txp5-using-pw/).
      I'd also like if PW used some proved libraries from (for example) Symfony (http://symfony.com/components) or Laravel (http://github.com/illuminate). Maybe because I'd love a "Processwire on Laravel (Components) with Craft-like design"
      Just interested in how Ryan is going to make PW adopt 5.3, PSR + Composer will push PHP in the future and there are great libraries that are well (unit-)tested and could be used.