Simple test with Selenium IDE

I’ve recorded short video with creation of simple test in Selenium IDE.

Testing site http://kontragent.info/.

If you have any questions, you can write them in post or comments to video.

Posted in Develpment | Tagged , | Leave a comment

Selenium IDE installaiton

Selenium IDE – web automation plugin. Can be used for testing web-interfaces.

To install Selenium reproduce following steps:

1. Install Firefox (Selenium IDE is plugin for Firefox).
Firefox can be downloaded here: http://www.mozilla.org/en-US/firefox/new/. If it not installed yet.

2. Download and install plugin Selenium IDE.
Download link can be found here: http://seleniumhq.org/download/.
Now the latest version is 1.7.2: http://release.seleniumhq.org/selenium-ide/1.7.2/selenium-ide-1.7.2.xpi.
If you will open this link in Firefox, plugin will be installed automaticly.
Except of that you can install Selenium IDE Buttons: https://addons.mozilla.org/en-US/firefox/addon/selenium-ide-buttons/.

3. Run Selenium IDE and record first test.
Selenium IDE anchor can be found here:
Selenium IDE anchor

Posted in Develpment | Tagged | Leave a comment

PHPUnit installation

Below list of commands, that are useful for PHPUnit installation.
Nothing special, but usually PHPUnit installation need more than two commands that you can find in manual.

First of all you should define option to automatic discover of channels:
pear config-set auto_discover 1
Channels can be added manual:
pear channel-discover pear.phpunit.de

Then try to install PHPUnit:
pear install –alldeps pear.phpunit.de/PHPUnit
–alldeps – to install all depencies of PHPUnit.

You’ll see error message probably. Something like that:
requires PEAR Installer (version >= 1.9.4).

In that case you have to upgrade PEAR:
pear upgrade PEAR

If you meet some problems with upgrade or in other update commands, try to clear cache.
pear clear-cache

After upgrading PEAR or after error that new version of PHPUnit doesn’t found, try to update information about channels:
pear update-channels

If something is wrong – uninstall PHPUnit PHPUnit:
pear uninstall phpunit

And repeat installation!

Posted in Develpment | Tagged | Leave a comment

Copy-paste sharing

Not long time ago I found, that some resources adding theirs url to text copied from page.
Before of that I saw it only in Microsoft Office OneNote. But here it depends on site and its scripts.

I’ve tried to implement something with clipboard, but recognized, that it is very difficult. And seems to be like development of bike.

After that I’ve tried to search, and found this video:

You see, that simple copy-paste is the simplest way to share information with somebody.

Difficult to say, on what information based this graphics, but they seems to be logic.

Here is site, where you can find easy api to put such sharing method on your site.

Use with pleasure!

Posted in Develpment | Tagged , , | Leave a comment

How to restrict right-click on images

Sometimes you need to restrict contextmenu over images. Simple way to prevent most of attempts to copy images from site. You know that there are other possibilities to retrieve images from page, but this way is very effective.

Here is implementation of disabling context menu on right-click.

For this code you need JQuery. I think it is not difficult to re-factor this code without JQuery.

Posted in Develpment | Tagged , , , | Leave a comment

Features of Zend_Validate_Float

Class Zend_Validate_Float is used to validate that input is float value.

Example of usage from manual:

This example is not really exact. If you’ll try to input this value in russian-languaged browser – you’ll see error message.
Russian-languaged browser sends header
Accept-Language:ru-RU,en-US,en
Zend Framework application sets locale to ru-RU, but in this locale other symbol to separate a decimal part – comma.
So in russian locale right example is:

The best practice is to set locale in validator:

or for application:

Posted in Develpment | Tagged , , | Leave a comment

Backup and restore mysql databases

How to create and restore mysql databases.

To create dump of mysql database, next command can be used:

For more information follow the link.

To restore database from file with dump, use next:

This commands are useful when big dumps are creating or restoring, if phpmyadmin generates timelimit error.

Posted in Develpment | Tagged , , , | Leave a comment

Zend_Db timezone definition after connection to MySQL

Sometimes you need to set timezone of mysql database manually.

Learn more about timezones in mysql here if needed.
To set timezone in mysql you can use command.

Timezone will changes to current session.
By default, timezone is the same as timezone of system.

If you want mysql to work with other timezone, you can set timezone manually with this command after connection.

db – Zend_Db object.

I found other solution in this blog.
So in other words if you using mysqli adapter for Zend_Db, we can set timezone in configuration file with adding string to it (уч, application.ini).

Full list of driver_options for mysqli you can find here.
Any option may be added to config (set encoding or set time format).

But, this feature can’t be used with PDO_MYSQL adapter.
In code of class Zend_Db_Adapter_Pdo_Mysql:

We see, that initialization option used to set encoding only. In class Zend_Db_Adapter_Pdo_Abstract I’m not found setting of options too.
Maybe I didn’t see something, but be careful, please.

Posted in Develpment | Tagged , , , , , , , | Leave a comment

ExtJS 3.2.1+ Multiselect – select all

ExtJS 3 has User eXtension (ux) Multiselect.
This component doesn’t has method to select all elements in-built. You can use Ctrl button to select elements one by one. Or you can press Shift and select range of elements. But this is not very comfortable.

Solution was found here.

You have to add method for this component:

And then for Multiselect component you can add usage of this method in tbar for example.

Posted in Develpment | Tagged , , | Leave a comment

Filtration of path to directory with Zend_Filter

I often come across when changing the agreement between the developers if the project continues long time.
One of these arrangements – how to write a directory path in the code – with or without the last slash.
For example, constants APPLICATION_PATH, BASEPATH or MAIN_PATH, which stores path to the project in the file system, or the path to the folder with images, with cookies, with cache…

In the end we see that paths stores in different manners. Like this:
/home/whyte624/htdocs/prj/
or like this:
/home/whyte624/htdocs/prj

To make paths similar, you can use next construction:

Below you can find the same construction in Zend_Filter_Interface. When you developing with Zend_Framework it may be comfortable for usage.

Example of usage:

Posted in Develpment | Tagged , , , | Leave a comment