четверг, 31 мая 2012 г.

Fedora & drupal7 + mysql install

Nothing difficult. Its my recipt and its case of taste how you can configure your development environment.
Lets install http server and mysql:
 yum groupinstall 'Web Server' 'MySQL Database'   

Drupal7 and phpmyadmin:
  yum install drupal7 phpmyadmin   

Mysql server start:
 systemctl start mysqld.service   

Password for mysql server root user:
 mysqladmin -u root password $PASSWORD   

Selinux disable.
In my opinion its less problems if selinux disabled at development workstation. But I do not recommend to disable it on production sites.
Disable link.

Configure drupal.conf:
 gedit /etc/httpd/conf.d/drupal7.conf   

Uncomment lines below to have site access by yourself: 
 Allow from   

Configure php.ini file. Rise up memory limit, file upload limit and enter your timezone.
 gedit /etc/php.ini   

I prefer working with localhost, where your development sites links looks like:
  • example.tst
  • commerce.tst
I am using drupal multisite feature and host drupal file into /home/www/sites directory instead of  default way.
Lets create required directory, symbol link, drupal sites files to new directory, add a $username and apache users to each groups and own drupal files by current user.
  rm /usr/share/drupal7/sites   
  mkdir /home/www   
  mkdir /home/www/sites   
  ln -s /home/www/sites /usr/share/drupal7   
  cp -f -r /etc/drupal7/* /home/www/sites  
  mkdir /home/www/sites/example.tst  
  cp -f -r /home/www/sites/default/* /home/www/sites/example.tst  
  gpasswd -a $username apache   
  gpasswd -a apache $username   
  cd /home   
  chown $username www -R   
  chgrp $username www -R   

Lets add custom localhost:
 gedit /etc/hosts   

That line:     example.tst   

Lets add apache virtual host:
 gedit /etc/httpd/conf/httpd.conf   
Scroll down to virtual hosts section, and uncomment line:
 NameVirtualHost *:80   

Then add new localhost to apache server:
 <VirtualHost *:80>  
   ServerAdmin username@example.com   
   DocumentRoot /usr/share/drupal7   
   ServerName example.tst   

Lets start apache:
 systemctl start httpd.service   

Now we can check, enter to your browser

Easy way to create databases is at:

Thats it.

вторник, 15 мая 2012 г.

Very simple SimpleTest drupal example

It was done to check basics of drupal SimpleTest work.
Module part just created a menu page with some "Hello World" text.
Test should check:

  1. If drupal slice generated by SimpleText exists
  2. If menu page exists
  3. If menu page has a string "Lets test it!"
Module code:
1:  <?php  
3:  function alternative_example_menu() {  
4:   $items['alt_example'] = array(   
5:    'title' => 'Hello World test example',  
6:    'description' => 'Its easy and fun',  
7:        'page callback' => '_alt_example_basic_instructions',  
8:    'page arguments' => array(t('Hello World')),   
9:    'access callback' => TRUE,  
10:    'type' => MENU_NORMAL_ITEM,  
11:   );  
12:   return $items;  
13:   }  
15:   function _alt_example_basic_instructions($content = NULL) {  
16:   $base_content = t('Lets test it!');  
17:   return '<div>' . $base_content . '</div><br />';  
18:  }  

Test code:
1:  <?php  
3:  /**  
4:   * @file  
5:   * Tests for alternative example module.  
6:   */  
7:  class AlternativeExampleTestCase extends DrupalWebTestCase {  
8:   protected $custom_user;  
10:   public static function getInfo() {  
11:    return array(  
12:     'name' => 'Hello world example functionality',  
13:     'description' => 'Checks "Hello world" string and page',  
14:     'group' => 'Alternative Examples',  
15:    );  
16:   }  
18:   /**  
19:    * Enable modules and create user with specific permissions.  
20:    */  
21:   public function setUp() {  
22:    parent::setUp('alternative_example');  
23:   }  
24:   function testAlternativeHelloExample() {  
25:        // Load site  
26:    $this->drupalGet('');  
27:    // Load page  
28:    $this->clickLink(t('Hello World test example'));  
29:    // Look for string  
30:    $this->assertText(t('Lets test it!'));  
31:   }  
32:   }  

Web output:

Also there is possible to run SimpleTest through drush:

Nothing enormous. Tests should run faster if they will done like unit tests way but i should check that option next time.