zend-framework,phpunit , Zendframework(1.12.11) view helper not found in phpunit

Zendframework(1.12.11) view helper not found in phpunit


Tag: zend-framework,phpunit

I have following directory structure for view helper in my zendframework project


and configuration setting in application.ini is

resources.view.helperPath = APPLICATION_PATH "/views/helpers"

and configuration in Bootstrap.php is

$view->setHelperPath(APPLICATION_PATH . "/views/helpers/");

in Test.php file naming convention is

class Zend_View_Helper_Test extends Zend_View_Helper_Abstract {}

and I am using helper function in module wherever I need it.When I run project via browser, application working fine without any error, but when I invoke phpunit for same application via command line I am getting error something like

Fatal error: Uncaught exception 'ErrorException' with message 'include_once(Zend\View\Helper\Test.php): failed to open stream: No such file or directory' in D:\

that means it's going to find Test.php file in zend server library view folder.I am not getting why it's working via browser and not working in phpunit via command line.


I got solution. I have replace my configuration setting of application.ini

resources.view.helperPath = APPLICATION_PATH "/views/helpers"


resources.view.helperPath.Application_View_Helper = APPLICATION_PATH "/views/helpers/"

and changed naming convention of Test.php with

class Application_View_Helper_Test extends Zend_View_Helper_Abstract {}

now zend loder will try to find view helper in application directory rather than Zend


Get Google Plus Images Using Zend Framework 1 Gdata

I've been searching for an answer for this for quite some time now. I've looked into the other questions here but couldn't find a relevant one to my situation. Googling the question wasn't helpful as well. Basically, I am using ZF1's Gdata class to access the photos api. This was...

How to route pages using text instead of IDs?

Currently, my Zend application routes using the URL: example.com/news/12 Selects the news with ID 12 to display on page. But the client wants to use only text, example: example.com/news/man-dies-after-burning-himself Does someone knows how can it be done?...

Zend And YouTube Not Deleting Videos

Until yesterday I could delete YouTube videos using Zend framework. I was using this code: $httpClient = Zend_Gdata_ClientLogin::getHttpClient( $username, $password, 'youtube', null, 'MySite', null, null, 'https://www.google.com/accounts/ClientLogin'); $yt = new Zend_Gdata_YouTube($httpClient, '', '', $myDevKey); $vid = $yt->getVideoEntry($myVidID, null, true); $yt->delete($vid); Now I am getting this error: Expected response code 200, got...

is not null condition in zend framework 2

I am new to zf and I've started working with zf2, I don't find much documentation for the syntax and all. My issue is how to write is not null condition in zf2 syntax. $select->where->notEqualTo('pe_name', ''); I've written for not equal to, now I need for is not null. I...

Symfony2 : PHPUnit How to use 'OR' condition in an assertion?

Using Symfony2 with PHPUnit, how can I use a OR condition in an assertion? In my case a client request can return codes 200 OR 302, but the assertEquals expect only one possibility. Is there any way to throw an exception is the code is not 200 AND 302? private...

Define type for PHPUnit's mock objects

I was wondering if its possible to use phpdoc to define some object in specific scope (inside a method only) as PHPUni's Mock, so in that method i can take advantage of type-hints, such as ->expected, ->methods and so on, just like when you just create the mock without addressing...

Zend date validator fail for format dd-mm-yyyy

I have the following code: <?php $dateString = '12.12.12'; $dateCheckArray['format'] = 'dd-mm-yyyy'; $validator = new Zend_Validate_Date($dateCheckArray); if ($validator->isValid($dateString)) { echo 'valid'; } else { echo 'invalid'; } The code works ok for most formats, but for the one specified it fails when using a . date instead of a -...

Symfony Crawler: how to check that a link to a particular page exists

I'm writing some functional tests and i want to verify that the Edit link exists on the page if the user is logged in. The link is a simple <a href="/profile/22/edit">Edit</a>. How can I filter it using the Crawler component of Symfony? One solution is this: $this->assertEquals(1, $crawler->filter('html:contains("<a href="/profile/22/edit">")')->count()); But...

Laravel 5.1 Unable to Run Test on User Password Mutator

I have a password mutator: /** * Mutator for setting the encryption on the user password. * * @param $password */ public function getPasswordAttribute($password) { $this->attributes[ 'password' ] = bcrypt($password); } That I'm trying to test: /** * A basic check of password mutator. * * @return void */ public...

How to send field name for required true validation in zend

Here is what my form field, $this->addElement( 'text', 'title', array( 'placeholder' => 'Title', 'class' => 'form-control', 'required' => true, 'filters' => array( 'StringTrim' ), 'autocomplete' => 'off', ) ); I Simply need the error string like: Title is required and can't be empty....

How To Write Acceptance Tests for Internet Explorer with: Selenium, PHPUnit and Mac OS X?

I'm trying to write acceptance tests for a project using multiple browsers. All the tests run fine with: Firefox, Chrome and Safari. However, I don't know how to run them in Internet Explorer. I use: PHPUnit, Selenium and Mac OS X. I also use VirtualBox with Windows 8 and Windows...

zend framework 2 nested module structrue in one main module

I am trying to create a app using zend framework 2. Have used structure as follow. Getting error class not found. Trying to created nested sub module login inside a main module called album. I have following structure: Album - src - Album - Controller - AlbumController.php - Form -...

Zend Framework 2 routing error: resolves to invalid controller class or alias

I'm trying to learn Zend Framework 2 and I have their skeleton application up and running. In order to access it I visit http://localhost:8080/. When visiting that link it displays their generic Zend page. What I want to be able to do is visit http://localhost:8080/application/test and have it bring me...

Can't run phpunit tests from command line

I am trying to run unit tests in a new laravel 5 application, using the phpunit framework. In the root path of my laravel application I ru the following command: ./vendor/bin/phpunit /tests/ExampleTest.php And then I get the following message: You need to set up the project dependencies using the following...

Understanding bootstrap, config.php, application.ini

I´m still beginner with Zend Framework. If I read different articles I wonder which are the differences between the three configuration files, bootstrap.php, config.php and application.ini. I only use the application.ini, my bootstrap so far ist empty (of course it is called in my index.php), at the moment I don´t...

controller action not found on production server

In my development area (wamp) everything works fine. Today I uploaded my whole project to my production webspace. I seems like in the production area, some paths are lost. First I saw that in my start layout (ZEND_Layout) my pictures aren't found. So I needed to change the paths to...

Zend paginator with AJAX

I have multiple albums listed on a page, next to each album are listed reviews about the album. Essentially this means there are many reviews about many albums on a single page. What would be the best approach to paginate each review section for each album? For example so each...

Wrong datatype for referenced entity on Doctrine ObjectSelect

I have a form which uses Doctrine's ObjectSelect to make a dropdown $this->add(array( 'name' => 'category', 'type' => 'DoctrineModule\Form\Element\ObjectSelect', 'options' => array( 'label' => 'Category', 'object_manager' => $em, 'target_class' => 'Blog\Entity\Category', 'property' => 'name' ), 'attributes' => array( 'required' => true ) )); the issue I have, is that this...

PHPunit expectation on Mock object is not fulfilled

Here is my class: public function __construct(Manager $moduleManager, Source\Yesno $yesNo) { $this->moduleManager = $moduleManager; $this->yesNo = $yesNo; } public function my1() { $this->moduleManager->isOutputEnabled(''); $this->yesNo->toOptionArray(); } public function my2() { $this->moduleManager->isOutputEnabled(''); $this->yesNo->toOptionArray(); } Here is my test: ... $this->observerMock = $this->getMock( 'path\to\Observer', null, [$this->moduleManagerMock, $this->yesNoMock], '', true ); ......

PhpUnit Testing stub method multiple return

I am doing some PHPUnit testing with symfony2. I am having a problem with one particular test. I am testing a response form one of my Class of course one response is true one false. I have a Mock of my Database and I have a stub for one of...

phpunit and http content-type

I have an API built in Laravel (Dingo) and it works perfectly. However I have a problem with implementing phpunit to unit test my API class ProductControllerTest extends TestCase { public function testInsertProductCase() { $data = array( , "description" => "Expensive Pen" , "price" => 100 ); $server = array();...

Failed installation of zend-escaper with Composer

I'm trying to install zend-escaper but I'm getting this error: This is strange as my PHP version (from phpinfo()) is 5.5.19, the message claims it is 5.3.5(!) which should satisfy the requirement anyway. My ZF version is 1.12.13 I'm using PHP Storm Can anyone help please? Thanks Tomasz...

Laravel 5 Model mocking

I have seen a few posts in various places about this and they all seem to have a similar answer. However for the life of me I cannot get the Mockery object working properly. The Attribute model looks like this namespace App\Models; use Illuminate\Database\Eloquent\Model; class Attribute extends Model { public...

Symfony2 & PHPUnit - Access getContainer()

I have a problem with my PHPUnit test on symfony2. To connect to my application, I use a web service, so I created a UserProvider. In my function loadUserByUsername I use symfony2 parameters saved in app/config/parameters.yml. As I'm not in a controller I need to use the global variable $kernel...

PhpStorm : Error in argument 1, char 2: option not found S

So PHPstorm is running the PHP code fine in its console when I click run; that's great but I want to see it in the browser. So, I created a Built in Server inside project. Now, when I clicked on Run -> Run Project, I'm getting error as: "Error in...

WP_UnitTestCase - how to configure the include_path correctly with phpunit PHAR

I'm trying to write a php unit test for my wordpress plugin and have been following the writing-wordpress-plugin-unit-tests tutorial. I've cloned the 'core.trac.wordpress.org/browser/tests/trunk/includes' locally I have installed phpunit via the PHAR mechanism as described here : https://phpunit.de/manual/current/en/installation.html#installation.requirements. I also have a composer.json configuration [14:11:[email protected]~]$ phpunit --version PHPUnit 4.7.3 by Sebastian...

What is the proper way to start a local PHP server, in PHP?

I want to make unit tests of a web crawling library with PHPUnit. To do so, I need to set up a temporary web server in local to test properly. I can do this: exec('php -S'); This looks ugly. And how can I even stop it? So, is there...

PHPunit call magic methods

I have magic method getData. Is it possible to call following inside unit test: $this->attributeMock ->method('getData') ->with('additional_data') ->willReturn('some value'); $this->attributeMock ->method('getData') ->with('is_default') ->willReturn('something'); When I do this, I got: Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'is_default' +'additional_data' Is there some another way?...

Socialengine addon Advanced Events Plugin v4.8.8p2 throwing errror on create

I've got a site set up with the base Socialengine setup going. I've installed most of the SocialEngineAddon suite of plugins, and for some reason, the Advanced Events plugin throws this error when I try and create one ie: example.com/appeals/create I've tried renaming back to the default site-event, but the...

Zend Skeleton Application album tutorial 404

As far as I can see I've followed the Zend skeleton application tutorial to the letter (I actually went through it twice with the same result) but when I try to access zf2-tutorial.localhost/album I get the following error: A 404 error occurred Page not found. The requested URL could not...

File upload form validation invalid

Current form: $main = new Zend_Form_SubForm(); $kids = new Zend_Form_SubForm(); $number = $main->addElement(... attribs and so on ...); $this->addSubForms(array('main'=>$main,'kids'=>$kids)); When I'm adding this file upload fields to my form: for($index = 1; $index <= 10; $index++) { $name = 'Image'.$index; $label = 'Image'.$index; $image = new Zend_Form_Element_File($name); $image->setLabel($label) ->addValidator('Count', true,...

Pass array on url using zend framework 2 routes

I have a web app that lets user make multiple searches and show the results of that searches all on the same page. Here's a basic structure: Search 1 - Attribute 1 = X - Attribute 3 = Y Search 2 -Attribute 2 = Z All these results are loaded...

Mocking or not registry-like object in phpunit tests

I'm facing some difficulties to mock a registry-like object in my tests, this might be because of a wrong design but it always end using $this->at(x) and, IMHO, therefore tightly coupling my test with tested code. For example, my registry-like object looks like something like this ( remember that its...

PHPUnit: Testing RestFul API with die response

I am trying to PHPUnit test an action in my ZF2 project. The APIs return a JSON string using die($jsonObject). This causes the PHPUnit test to stop processing and just die a JSON response. public function testStartupAction() { $this->dispatch('/api/v3/startup', "POST", array()); $this->assertJson('{"status":false,"message":"Please enter the UID","data":null}'); } assetJson method is never...

Unable to find wrapper when testing Guzzle call with PHPUnit

I am writing a unit test for an API that I am developing. The API is written in the Codeigniter framework, that calls another API using Guzzle. The test I am writing verifies that the API call returns the correct response. The Test.php file contains the following code require '/application/libraries/apiWrappers/Breathehr.php';...

Zend Framework 2 - Sending form using Zend\Mail

So i'm making a contact page. Of course it will have a form, which needs to be sent. I made the class to send email: <?php namespace Site\Mail; use Zend\Mail\Message; use Zend\Mail\Transport\Sendmail; class SendEMail { public function SendEMail($to, $from, $subject, $body) { $message = new Message(); $message->addTo($to) ->addFrom($from) ->setSubject($subject) ->setBody($body);...

Laravel 5.1 PHPUnit with “use DatabaseMigrations;” Produces Error when Accessing Test DB

I'm just learning PHPUnit with Laravel 5.1. I'm using "use DatabaseMigrations" to migrate the test database for each test, which I set in my phpunit.xml: <php> ... <env name="DB_DATABASE" value="project_test"/> ... </php> I've setup a bunch of basic tests as I go along to check instantiation, factories, etc, but I...

Symfony2: changing the request class and updating the test environment

I have modified the base Request class of my application as explained in the accepted answer of this question. It works very well, except when launching my functional tests, I get the following error: Controller "My\Bundle\AppBundle\Controller\MyController::searchAction()" requires that you provide a value for the "$request" argument (because there is no...

How to unit test a data extraction method

I have created a method which interacts with a framework, pulling out order items which have a completed status. However, how can I unit test my method to ensure it behaves correctly... class A { public function extractData() { // extract data from framework $dataCollection = FrameworkX->getDataCollection('sales/orders'); $dataCollection->filter('state', 'complete'); return...

Symfony Functional Testing: how to understand why the test fails (with a 500 Error)

I'm writing functional tests for a controller that registers a new user in the app. The test I'm writing fails because of a 500 HTTP error. I'm using $response = $client->getResponse(); print_r($response->getContent());exit; to print the HTML to see what is happening but the HTML is incomplete in my console (PHPStorm)...

database restore for integration tests with phpunit

I'm using phpunit and I'd like to know if there is a correct form for restoring the database before running integration tests. At the moment I'm calling an sql server script with php exec() on the testcase setUp method, but don't know if this is the best choice class...

Bootstrap of Zend Module is not loading

I am new in working with zend so I am facing this problem from the past two days. I have searched a lot but still can not find any solution. Possible duplicate of Zend Module Bootstrap does not load but it still can not solve my problem. In my User...

Travis CI is not case-sensitive by default?

I have a php project that has composer dependencies which are inherently tested in the code path of my unit tests. Here's my sample code: <?php // where FooBar is a composer package but I'm purposely typing it incorrectly here use \fooBaR public function appendNameToWords(array $words, $name) { $start =...

Uninstalling php 5.3 in ubuntu 14.04

I have installed php 5.3 manually by executing commands like make & make install. But I need to upgrade it to v5.5 therefore I deleted all the directories related to php5 using sudo command. But when I run php -v Still I am getting PHP 5.3.29 (cli) (built: Jun 8...

Zend_Pdf how to reduce the loading time of images?

I built an pdf document which is based on database records of 2 related tables. The mastertable contains shopdata with logos. In the records I of course don't save the image itself, but only the pathinfo. The detailtable just contains meeting dates, no problems with this one. If I start...

Error in Array comparison in php

Below are the sample arrays I'm Comparing. Table 1 $csvData= ( [0] =&gt; Array ( [Account Number] =&gt; 1.01100156278101E+15 [Posting Date] =&gt; 2014/07/08 [Value Date] =&gt; 2014/07/08 [Description] =&gt; Cash Withdrawal by Cheque-173320--TT1421957901 [Debit Amount] =&gt; 2000 [Credit Amount] =&gt; [Running Balance] =&gt; 388392.62 ) [1] =&gt; Array ( [Account...

Cakephp 3 - MissingDatasourceConfigException when running phpunit test

I am trying to run some unit tests in CakePHP 3 with PHPUnit 4.7.3, but I`m getting the following error: PHPUnit 4.7.3 by Sebastian Bergmann and contributors. There was 1 error: 1) App\Test\TestCase\Model\Table\MoviesTableTest::testFindMoviesByGenre Cake\Datasource\Exception\MissingDatasourceConfigException: The datasource configuration "default" was not found. C:\xampp\htdocs\movie-pal\vendor\cakephp\cakephp\src\Datasource\ConnectionManager.php:188 C:\xampp\htdocs\movie-pal\vendor\cakephp\cakephp\src\ORM\TableRegistry.php:191...

Transfert a Zend Project to Symfony

I have a project made using Zend. My boss asked me to change the technology to Symfony 2.7. Is there a way to transfer the project ? Or to take some files into Symfony ? Or should I begin all the project from scratch using Symfony ? Thanks !...

phpunit no tests executed

I have a 'No tests executed' with phpunit.. This line works $ phpunit install/InstallDbTest.php ... <result expected> ... $ cat suites/installtests.xml <phpunit> <testsuites> <testsuite name="database"> <file>install/InstallDbTest.php</file> </testsuite> </testsuites> </phpunit> $ phpunit -c suites/installtests.xml PHPUnit 4.7.4 by Sebastian Bergmann and contributors. Time: 130 ms, Memory: 11.25Mb No tests executed! Does anyone...

How can I make PHPUnit ignore a file pattern?

I'm doing Code Coverage reports for a project and there's a ton of files that are included or required while tests are running that are not actually required to be tested or added to coverage reports (I'm using Zend Framework 2; config + Module files are the culprit here). Is...