Functional testing with authentication and Symfony 2.3, FOSUserBundle

Running functional tests of Symfony 2.3 PHP applications where FOSUserBundle handles users is unfortunately easier said than done as far as user authentication is concerned. As I couldn’t find a working code example anywhere that showed how to authenticate a user before executing a functional test, I am publishing the code that I got to work in the end.

Simply put this function into your test class and call it to obtain a fully authenticated test client object.

protected function createAuthorizedClient()
 $client = static::createClient();
 $container = $client->getContainer();

 $session = $container->get('session');
 /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */
 $userManager = $container->get('fos_user.user_manager');
 /** @var $loginManager \FOS\UserBundle\Security\LoginManager */
 $loginManager = $container->get('');
 $firewallName = $container->getParameter('fos_user.firewall_name');

 $user = $userManager->findUserBy(array('username' => 'myusername'));
 $loginManager->loginUser($firewallName, $user);

 // save the login token into the session and put it in a cookie
 $container->get('session')->set('_security_' . $firewallName, 
 $client->getCookieJar()->set(new Cookie($session->getName(), $session->getId()));

 return $client;

Feel free to leave feedback.


QmlOgre is now a library

After some extensive refactoring, QmlOgre is now a library, making the integration of Ogre into Qt QML scenes even easier. The library comes with the original QmlOgre sample application, adapted to work with the new library code.

Let me know in the comments what you think. More updates to the code are on the way as time permits.

QmlOgre Screenshot

How to integrate Ogre3D into a Qt5 QML scene

Recently I’ve been checking out again how to integrate Ogre3D into a Qt application. My previous effort Cutexture can be found here, here and the code here. This was nice as a simple integration but didn’t use modern graphics systems as efficiently as it could.

Fortunately the people at Nokia (when they were still interested in Qt) did publish a demo application qmlogre here that integrates Ogre3D into a Qt Quick QML scene by having Ogre render into an OpenGL Frame Buffer Object (FBO) which is in turn added to the QML scene as a textured item. However, this demo was relying on internal Qt headers that are not supposed to be used in production projects.

With a helpful comment I found here, I was able to update the qmlogre example to no longer rely on those internal Qt headers and to build fine with the latest stable Qt 5.0.1. In the hope that others may find it useful, I’ve made the revised code available on my Github account at

Let me know in the comments what you think.

Edit: Here is a video of the original qmlogre application.

How to use the new OpenGL features of Qt5

Qt5 hosts a couple of new features to simplify working with OpenGL, with a helpful introduction given by Dr. Sean Harmer at Qt Developer Days 2012:

Unfortunately the source code to the presentations was not made available. To remedy, I’ve created a GitHub repository of the “Hello World” triangle example that is shown at the beginning of the presentation and adapted it to work with GLSL 1.30 and vanilla Qt5.

Find the code at

Taking Android screenshots under Ubuntu 12.04

Before being able to take screenshots of an Android device connected via USB cable to a machine running Ubuntu 12.04, it is necessary to instruct Ubuntu to give the user full permissions over the device. Unfortunately the tutorials that I found on the web didn’t work, so here is what has worked for me.

  1. Connect the device and get the vendor and product ID by running

    in a console.
    The output should contain one line listing your Android device, similar to the following:

    Bus 002 Device 004: ID 18d1:4e22 Google Inc. Nexus S (debug)

    Note the two 4 character hex values separated by a colon behind ID, these the vendor ID and product ID for your device.

  2. With a text editor, create/edit the file

    and place the following text in it:

    SUBSYSTEM=="usb", ATTRS{idVendor}=="VENDORID", ATTR{idProduct}=="PRODUCTID", MODE="0666"

    Replace VENDORID and PRODUCTID with the values retrieved in step 1. Save the file and close the editor.

  3. Disconnect your device.
  4. Kill your Android debug server if it was running by executing
    ./platform-tools/adb kill-server

    from console in the Android SDK directory.

  5. Restart the udev subsystem to let it detect the rule created in step 2 with
    sudo service udev restart
  6. Reconnect your device.
  7. Run

    from console in your Android SDK directory to bring up the Dalvik Debug Monitor (DDM).

  8. In DDM, select your device in the top-left device list, wait a few seconds, then select “Device -> Screen Capture” from the application menu.

OGRE 3D 1.7 Beginner’s Guide: book review & giveaway

Ogre 3D 1.7 - Beginner's Guide

After announcing Cutexture, Packt Publishing asked me to review their new book “Ogre 3D 1.7 Beginner’s Guide” by Felix Kerger which I would now like to review in this post. The book is structured into nine chapters, aiming to cover everything from installing Ogre, managing 3D scenes, models, materials and animations to an overview of third party Ogre extensions. It is targeted at 3D programming novices who have already got some C++ development experience and who are keen on creating a 3D application or game. Continue reading

Cutexture: A Framework for Qt User Interfaces in Ogre3D

Today, I’d like to write about the results of a development effort which I undertook together with former co-worker Kevin Lang in our spare-time. Our goal was to create a small but fine PC game but unfortunately it never saw the light of the day. We therefore decided to release the game-independent source code of these efforts to the public as we believe we developed a novel approach to integrating Qt User Interfaces into the Ogre3D development framework.

In a nutshell, this new framework called “Cutexture” should provide developers with the following benefits over off-the-shelf User Interface solutions available for Ogre3D:

  • The full range of Qt’s widgets can be used in Ogre3D, including the Webkit webbrowser component, enabling completely new ways of integrating Web content into 3D environments.
  • Powerful: Qt is one of the most powerful User Interface toolkits currently available.
  • Ease of development: Qt’s .ui files are supported for rapid User Interface development with Qt Designer.
  • Reliable: Using the proven Qt framework, widgets are rendered into a texture instead of relying on unstable overlay techniques provided by desktop environments.
  • Flexible: Possibility to extend Cutexture to use Qt widgets as textures on arbitrary Ogre objects.
  • Open Source: Cutexture is available under the “MIT license”, thereby providing full source code access to the framework while allowing the development of proprietary (closed source) applications.


Continue reading

You get the impression that Linux is becoming mainstream…

… when the largest German drugstore chain starts offering a Linux version of its end-user software for designing and ordering photo products such as photo books and calendars.


Screenshot of the photo application running under the KDE 4 desktop.

(For the technically inclined: The application was developed with the Qt library.)

Using FacetZoom: Arranging discrete data

This entry describes the code for integrating FacetZoom into an application in order to arrange discrete data (e.g. photos) according to a non time-based facet (e.g. location, person, etc.).

Internally, the FacetZoom widget utilizes the Qt QGraphicsView class for visualization. Consequently, it offers methods in its interface which are best suited for data visualizations which make use of QGraphicsView as well. The interface class is called DataPlacementControlInterface.

To receive a notification every time the FacetZoom widget is modified and the data visualization needs to be updated, a placementChangedSignal is emitted on the FacetZoom widget. This signal can be connected to only on the FacetZoom class as Qt does not permit offering Signals in virtual (interface) classes. Therefore, we can connect a customViewInstance subclass of QGraphicsView to a FacetZoom instance fzInstance as follows:



Now, every time dpcChangedSlot is invoked by an emission of placementChangedSignal, the vizInstance receives a pointer to the emitting FacetZoom widget along with the call. This way, the visualization instance is able to retrieve the information needed to arrange the data in its view.

Continue reading