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.
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.
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:

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!
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!
Class Zend_Validate_Float is used to validate that input is float value.
Example of usage from manual:
|
1 2 |
$validator = new Zend_Validate_Float();
$validator->isValid(1234.5); // returns true |
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:
|
1 2 |
$validator = new Zend_Validate_Float();
$validator->isValid(1234,5); // returns true |
The best practice is to set locale in validator:
|
1 2 |
$validator = new Zend_Validate_Float(array('locale' => 'en'));
$validator->isValid(1234.5); // returns true |
or for application:
|
1 2 |
$locale=new Zend_Locale('en-US');
Zend_Registry::set("Zend_Locale",$locale); |
How to create and restore mysql databases.
To create dump of mysql database, next command can be used:
|
1 |
mysqldump --user={user} --password={password} --databases {dbname} > {filename} |
For more information follow the link.
To restore database from file with dump, use next:
|
1 |
mysql --user={user} --password={password} {dbname} < {filename} |
This commands are useful when big dumps are creating or restoring, if phpmyadmin generates timelimit error.
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.
|
1 |
set time_zone = '-4:00'; |
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.
|
1 |
$db->query("set time_zone = '-4:00'"); |
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).
|
1 |
resources.db.params.driver_options.MYSQLI_INIT_COMMAND = "set time_zone = '-4:00'" |
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:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/**
* Creates a PDO object and connects to the database.
*
* @return void
* @throws Zend_Db_Adapter_Exception
*/
protected function _connect()
{
if ($this->_connection) {
return;
}
if (!empty($this->_config['charset'])) {
$initCommand = "SET NAMES '" . $this->_config['charset'] . "'";
$this->_config['driver_options'][1002] = $initCommand; // 1002 = PDO::MYSQL_ATTR_INIT_COMMAND
}
parent::_connect();
} |
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.
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:
|
1 2 3 4 5 6 |
Ext.override(Ext.ux.form.MultiSelect, {
selectAll : function() {
var ids = this.store.collect(this.valueField);
this.setValue(ids);
}
}); |
And then for Multiselect component you can add usage of this method in tbar for example.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
tbar:[
{
text: 'All',
handler: function(){
Ext.getCmp('west-panel').getForm().findField('multiselect_field').selectAll();
}
},
{
text: 'Clear',
handler: function(){
Ext.getCmp('west-panel').getForm().findField('multiselect_field').reset();
}
},
], |
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:
|
1 |
$dir=rtrim($dir, '/\\'); |
Below you can find the same construction in Zend_Filter_Interface. When you developing with Zend_Framework it may be comfortable for usage.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?php
/**
* @see Zend_Filter_Interface
*/
require_once 'Zend/Filter/Interface.php';
/**
* @category Zend
* @package Zend_Filter
*/
class App_Filter_DirLastSlash implements Zend_Filter_Interface
{
/**
* Returns directory path without last slash
*
* @param string $value
* @return string
*/
public function filter($value)
{
return rtrim($value, '/\\');
}
} |
Example of usage:
|
1 2 |
$filter=new App_Filter_DirLastSlash();
$dir=$filter->filter($dir); |