Error in sample functional tests with Yii - php

Recently I've discovered Yii framework and started learning it. I've generated app skeleton using yiic tool, installed PHPUnit, SeleniumRC and attempted to run functional tests provided by skeleton app (I didn't change anything).
> phpunit functional/SiteTest.php
Report said following:
There was 1 error:
1) SiteTest::testLoginLogout
PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete().
ERROR: Element link=Logout not found.
I found that there was a 'Logout (demo)' link, not just 'Logout'. If I change php code in testcase, all tests pass ok. Is it error of Yii developers or am I missing something?

Yii 1.1.6 fixes this bug.
if($this->isTextPresent('Logout'))
$this->clickAndWait('link=Logout');

Related

Running PHPUnit from eclipse PHPUnitLogger error and a port 7478 error

I can run phpunit effortlessly from commandline, no hitches there, but I thought it might be easier if I can run it directly from eclipse. I have never set up eclipse PHPUnit before so I followed a youtube video to set up PHPunit.
That one fails just as bad as the default php unit run the PDT enviroment provides.
But when I set up PHPUnit I get two errors and 0 hits on Google where to start resolving the issues.
I'm using php 7.2 TS on a windows 7 64bit system with Eclipse Oxygen.
When I try to run the tests I get the following error as a popup
Cannot launch PHPUnit tests (port address 7478): Accept timed out
And in the console I get:
PHPUnit 6.2.4 by Sebastian Bergmann and contributors.
Could not use "PHPUnitLogger" as printer.
I'm trying to run the tests under OctoberCMS, which is based upon Laravel. And as I said, the unit tests work as they should in the console.
What do I need to change to get PHPUnit working in eclipse?
I stumbled over this question since I had the same problem with Eclipse. In case someone else finds this problem, here is my solution:
In the "plugins" folder of your Eclipse installation you can find the File PHPUnitLogger.php. On Linux you can find it with the "locate" command, but it should be something like
<your_eclipse_folder>/plugins/org.eclipse.php.phpunit_<some_version>/resources/printer/PHPUnitLogger.php
Load this file in your bootstrap.php via require_once.

Phalcon INVO project register process fails

I set up the INVO project of Phalcon to get used to the framework. However, I'm facing a problem with the register process. When I try to register, I get the error
Catchable fatal error: Argument 1 passed to Phalcon\Mvc\Model::validate() must implement interface Phalcon\ValidationInterface, instance of Phalcon\Mvc\Model\Validator\Email given in C:\xampp\htdocs\invo\app\models\Users.php on line 13
I haven't changed anything code-wise and I searched Google for a solution to this, but I haven't found anything. Any ideas on how to solve this issue?
You are using Phalcon 2.1 beta but INVO uses stable 2.0

Can't run tests provided in Slim Framework

I'm trying to make a simple rest client for my android app. I would like to do than in TDD way, but for that I need simple working configuration for all actions (GET, POST, and so on). After some struggling I was able to make test work with get requests. Unfortunately with Post routes things didn't go well. When testing (netbeans 8.0.2 + phpunit) on local server (xampp 5.6.3) all I get is 404 error. Same thing if I run method being tested with Advanced Rest Client Application (chrome extension). When I send my rest files to live hosting then method in question works as it should.
After searching for some days (read about everything with 404 errors on Slim Framework) I decided to start with something which should work right of the box. Slim framework comes with simple demo app and some tests. Here I have another error which prevents start of tests:
Fatal error: Class 'Slim\Middleware' not found in C:\xampp\htdocs\web\local\codeguy-Slim-04958a1\tests\MiddlewareTest.php on line 3
As far I can tell I have something wrong with my xampp server but I don't have any more ideas how to fix this. So If somebody could show me correct way to setup Netbeans, Xampp, Slim and phpunit(I'm running it from IDE (ALT + F6)) then I would be able to build my rest api on top of that.
I just tried the following, maybe it might suggest a different route to try?
git clone https://github.com/codeguy/Slim.git
cd Slim
// Edit composer.json to include "phpunit/phpunit": "4.3.*"
curl -sS https://getcomposer.org/installer | php
php composer.phar install
./vendor/bin/phpunit
A few tests failed for me, surprisingly - so that would need digging into. But all classes were found.
Everything should work though, as the project seems to be building OK over on Travis CI.
I've found out what was wrong with my tests and with test provided with framework. I didn't know that I had to set bootstrap.php file in Project configuration of Netbeans.

Yii Framework 2.0 Console Application Error Unknown Property enableCookieValidation

I am learning how to create console application with Yii 2.0. I have downloaded the Yii advanced package 2.0 which already has the default console application in it. I have copied that console application and pasted in my project. In that console application I have a TestController and an actionIndex() method, very basic following the documentation of Yii 2.0. When I run the command within my project:
php yii test
I've got the following error:
Exception 'yii\base\UnknownPropertyException' with message 'Setting unknown property: yii\console\Request::enableCookieValidation'
When I run the same command in the downloaded Yii advanced application. It works fine. I don't know what causes the error in my project and where to check it. Does anyone have a clue? If you ask how my console application look like, it is literally copied from the Yii 2.0 advanced application. If I run:
php yii migrate
I get the same error.
Seems like you having this line in your console application config:
'request' => [
'enableCookieValidation' => ...
],
You should delete it because yii\console\Request compared to yii\web\Request simply doesn't have that property.
Rememeber that in Yii advanced template, there are three settings instances; common/config is the first instance, after that , many of these properties override

Using janrain's OpenId php libs' test scripts. (PHPUnit)

I'm trying to run the test scripts that come with JanRain's php openid libraries. I've installed PHPUnit using pear. When I try to run the scripts I get:
Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /var/www/localhost/htdocs/openid/openid/Tests/Auth/OpenID/StoreTest.php on line 72
I'm sure this is a really simple issue. I just can't figure out what's wrong.
I don't see anywhere that the PHPUnit files get included, so do I need to make them automatically included somewhere?
server info: http://info.theunlink.com/info.php
I'm using the latest git sources: http://github.com/openid/php-openid
(I'm trying to run the test stuff because I get "OpenID authentication failed: Nonce already used or out of range" every other time I try to login and I'm trying to find where the issue is.)
What PHPUnit version do you have? There is a really ancient one in PEAR, you need a recent one - 3.4
With that out of the way, how exactly are you running the tests? I did a git clone and then executed command:
php admin/texttest.php
This did run at least part of the test suite.

Categories