Archive

Archive for the ‘PHP-Programming’ Category

Exception: Serialization of ‘Mage_Core_Model_Config_Element’ is not allowed

March 6th, 2011 Sebastian Förster 1 comment

if you get the Error above by executing Magento Unittest look at your Configuration Options for PHPUnit. backupStaticAttributes must set to false.

Categories: PHP-Programming Tags: , ,

Shell Script to install php

January 22nd, 2011 Sebastian Förster No comments

For my work I have developed a little shellscript to configure and install my php installations:

My folder Structure is like following:

/usr/local/bin/php/phpversion
There is a symlink to current phpversion:
/usr/local/bin/php/current -> /usr/local/bin/php/phpversion

The Script configure php with some standard flags and create the binary files in the folders above:

#!/bin/bash
 
EXTENSION_DIR="/usr/local/bin/php/$1/extensions"
 
if [ $# -lt 1 ]; then
  echo "Usage: $0 php5.3.2 [more options for php configure]"
  exit;
fi
if [ -d /usr/local/bin/php/$1/ ]; then
   mkdir /usr/local/bin/php/$1
fi
 
OPTIONS="$2"
OPTIONS="--without-pear --with-pdo-mysql --with-mysql --with-mysqli --without-pear --enable-force-cgi-redirect $OPTIONS"
cd $1
./configure --prefix=/usr/local/bin/php/$1 $OPTIONS
if [ "$?" -eq "0" ]; then
  make
  make install
fi
if [ -d "$EXTENSION_DIR" ]; then
  mkdir -p $EXTENSION_DIR
fi

you can pass additional configure arguments as second parameter to the script.

Usage

  • Download the php package: wget http://php.net/get…..
  • Extract files: tar xvzf php.tgz
  • execute the script ./scriptname phpfoldername

Now I share the script on github:

https://github.com/Forestsoft-de/forestsoft/tree/master/bash/php

Categories: PHP-Programming, Server Tags:

PHPUnit Selenium Driver and Screenshots

December 8th, 2010 Sebastian Förster No comments

If you use PHUnit Selenium Extension with Possibilty to take Screenshots on Error be aware that your Operating System where you run the test is the same that the Selenium Server runs.

PHPUnit use DIRECTORY_SEPARATOR to tell Selenium Server where Screenshots should be saved.

If you run the test under Windows and your Selenium Server is on a Linux Host PHPUnit tell Selenium that it should store Screenshot in Path i.e. /var/www/screenshots\filename.png

This crash with an Permission denied Error.

In the case that you use this kind of setup you should change the onNotSuccessfulTest method in File SeleniumTestCase.php of PHPUnit:

<?php
 protected function onNotSuccessfulTest(Exception $e)
    {
        if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
            $buffer  = 'Current URL: ' . $this->drivers[0]->getLocation() .
                       "\n";
            $message = $e->getCustomMessage();
            if ($this->captureScreenshotOnFailure &&
                !empty($this->screenshotPath) &&
                !empty($this->screenshotUrl)) {
                $this->drivers[0]->captureEntirePageScreenshot(
//                  $this->screenshotPath . DIRECTORY_SEPARATOR . $this->testId .  '.png'
                    $this->screenshotPath . $this->testId .  '.png'
                );
 
                $buffer .= 'Screenshot: ' . $this->screenshotUrl . '/' .
                           $this->testId . ".png\n";
            }
        }
 
        if ($this->autoStop) {
            try {
                $this->stop();
            }
 
            catch (RuntimeException $e) {
            }
        }
 
        if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
            if (!empty($message)) {
                $buffer .= "\n" . $message;
            }
 
            $e->setCustomMessage($buffer);
        }
 
        throw $e;
    }

It should possible to set this in an Operating System Variable.

Categories: PHP-Programming Tags: