The document discusses continuous integration for Drupal projects. It covers tools like Jenkins, Drush, Phing, and Features that allow automating build, test, and deployment processes. Continuous integration helps catch errors early, keep code changes integrated frequently, and make it easier to deploy updates. The document provides overviews and examples of setting up continuous integration for Drupal projects.
Getting Started With Jenkins And DrupalPhilip Norton
Jenkins is a really powerful tool for automating things like code analysis, testing and even deployment. Getting started with Jenkins, especially with Drupal, is a challenge and can be quite difficult for a beginner to the system. In this session I'll show you how to install Jenkins, how to configure things like authentication and then how to do some interesting things with the tool. I'll show some real life examples of things that can be done with the tool on your Drupal sites to do things like run cron jobs, syntax check the code or even automatically copying code to your web servers.
Lots of customers demand a preview of the the new features before they go live, so we need a solid way to show them our work before applying it on the production environment. You may already use features (good!), but you still struggle with managing your changes? I will show you how my company LimoenGroen uses tools like Jenkins to automatically deploy changes to their Test environment and how to apply these changes to the Acceptance and Production environments.
Drupal Continuous Integration with Jenkins - DeployJohn Smith
Simple deployment setup for Jenkins. This tutorial assumes you have used our previously released "Drupal Continuous Integration with Jenkins" tutorial to setup your Jenkins server. This document is being released under the Creative Commons CC0 license.
Enjoy!
Drupal Continuous Integration with Jenkins - The BasicsJohn Smith
Please check out our new SlideShow of setting up and configuring a Jenkins Continuous Integration server for use within a Drupal development environment. We walk you through the steps of installing Ubuntu 10.04 LTS, Jenkins, Drush and several other PHP coding tools and Drupal Modules to help check your code against current Drupal standards. Then we walk you through creating a git post-receive script, and Jenkins job to pull it all together.
IBM Drupal Users Group Discussion on Managing and Deploying ConfigurationDevelopment Seed
Presentation to the IBM Drupal Users Group on improving configuration management in Drupal using the Features module and exportables. This is becoming a best practice for configuration management.
Getting Started With Jenkins And DrupalPhilip Norton
Jenkins is a really powerful tool for automating things like code analysis, testing and even deployment. Getting started with Jenkins, especially with Drupal, is a challenge and can be quite difficult for a beginner to the system. In this session I'll show you how to install Jenkins, how to configure things like authentication and then how to do some interesting things with the tool. I'll show some real life examples of things that can be done with the tool on your Drupal sites to do things like run cron jobs, syntax check the code or even automatically copying code to your web servers.
Lots of customers demand a preview of the the new features before they go live, so we need a solid way to show them our work before applying it on the production environment. You may already use features (good!), but you still struggle with managing your changes? I will show you how my company LimoenGroen uses tools like Jenkins to automatically deploy changes to their Test environment and how to apply these changes to the Acceptance and Production environments.
Drupal Continuous Integration with Jenkins - DeployJohn Smith
Simple deployment setup for Jenkins. This tutorial assumes you have used our previously released "Drupal Continuous Integration with Jenkins" tutorial to setup your Jenkins server. This document is being released under the Creative Commons CC0 license.
Enjoy!
Drupal Continuous Integration with Jenkins - The BasicsJohn Smith
Please check out our new SlideShow of setting up and configuring a Jenkins Continuous Integration server for use within a Drupal development environment. We walk you through the steps of installing Ubuntu 10.04 LTS, Jenkins, Drush and several other PHP coding tools and Drupal Modules to help check your code against current Drupal standards. Then we walk you through creating a git post-receive script, and Jenkins job to pull it all together.
IBM Drupal Users Group Discussion on Managing and Deploying ConfigurationDevelopment Seed
Presentation to the IBM Drupal Users Group on improving configuration management in Drupal using the Features module and exportables. This is becoming a best practice for configuration management.
Implementing CI CD UiPath Using Jenkins PluginSatish Prasad
Implementing CI-CD UiPath Using Jenkins Plugin.
Whats is Covered
Basic of Jenkins to get started
2. Key Jenkins concepts to remember
3. Install and configure UiPath Jenkins Plugin
4. Building pipeline using Jenkins for Build, Test and Deploy
5. Working example (Jenkins files)
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)CloudBees
Delivering value to the business faster thanks to Continuous Delivery and DevOps is the new mantra of IT organizations. In this webinar, CloudBees will discuss how Jenkins, the most popular open source Continuous Integration tool, allows DevOps teams to implement Continuous Delivery.
You will learn how to:
* Orchestrate Continuous Delivery pipelines with the new workflow feature,
* Scale Jenkins horizontally in your organization using Jenkins Operations Center by CloudBees,
* Implement end to end traceability with Jenkins and Puppet and Chef.
http://devops.com/news/ci-and-cd-across-enterprise-jenkins/
https://github.com/CloudBees-community/vagrant-puppet-petclinic
Vous n'avez pas pu assister à la journée DevOps by Xebia ? Voici la présentation de Cyrille Le Clerc (Cloudbees) et Geoffroy Warrin (Xebia) : "De l'intégration continue au déploiement continu avec Jenkins"
Flipkart.com is one of India's top 100 websites in terms of traffic. We use continuous deployment techniques to achieve quick deployments multiple times a day. Techniques and best practices we follow that we believe could be interesting to many others.
Jenkins and Chef: Infrastructure CI and Automated DeploymentDan Stine
This presentation discusses two key components of our deployment pipeline: Continuous integration of Chef code and automated deployment of Java applications. CI jobs for Chef code run static analysis and then provision, configure and test EC2 instances. Release jobs publish new cookbook versions to the Chef server. Deployment jobs identify target EC2 and VMware nodes and orchestrate Chef client runs. The flexibility of Jenkins is essential to our overall delivery architecture.
Deploying your Drupal site, Upgrading your Drupal Site, Scaling, Clustering and Monitoring it ... all topics Developers are often not involved with ...
Devops For Drupal explains the Devops problem, to a Drupal audience .
Introduction to Infrastructure as Code & Automation / Introduction to ChefNathen Harvey
Your customers expect you to continuously deliver delightful experiences. This means that you’ll need to continuously deliver application and infrastructure updates. Hand-crafted servers lovingly built and maintained by a system administrator are a thing of the past. Golden images are fine for initial provisioning but will quickly fail as your configuration requirements change over time.
It’s time for you to fully automate the provisioning and management of your infrastructure components. Welcome to the world of infrastructure as code! In this new world, you’ll be able to programmatically provision and configure the components of your infrastructure.
Disposable infrastructure whose provisioning, configuration, and on-going maintenance is fully automated allow you to change the way you build and deliver applications. Move your applications and infrastructure towards continuous delivery.
In this talk, we’ll explore the ideas behind “infrastructure as code” and, specifically, look at how Chef allows you to fully automate your infrastructure. If you’re brave enough, we’ll even let you get your hands on some Chef and experience the delight of using Chef to build and deploy some infrastructure components.
PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...Puppet
Here are the slides fromCarl Caum and Brian Dawson's PuppetConf 2016 presentation called Continuous Delivery and DevOps with Jenkins and Puppet Enterprise. Watch the videos at https://www.youtube.com/playlist?list=PLV86BgbREluVjwwt-9UL8u2Uy8xnzpIqa
DevOps is a one-stop solution for all software engineering. From creating the software to implementing it in real-time, DevOps does all. This creates an infinite demand for excellent DevOps developers in the market. Since the platform is quite fast and effective, it is attracting the attention of many organizations that are looking to develop a software solution for their own business. Thus, here are a few DevOps interview questions that can help you crack an interview.
First Steps in Drupal Code Driven DevelopmentNuvole
"First Steps in Code Driven Development" covers basic techniques and good practices. Presented during the "Developer Session" at Krimson office, Antwerp (BE), the 27th of May 2010.
Implementing CI CD UiPath Using Jenkins PluginSatish Prasad
Implementing CI-CD UiPath Using Jenkins Plugin.
Whats is Covered
Basic of Jenkins to get started
2. Key Jenkins concepts to remember
3. Install and configure UiPath Jenkins Plugin
4. Building pipeline using Jenkins for Build, Test and Deploy
5. Working example (Jenkins files)
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)CloudBees
Delivering value to the business faster thanks to Continuous Delivery and DevOps is the new mantra of IT organizations. In this webinar, CloudBees will discuss how Jenkins, the most popular open source Continuous Integration tool, allows DevOps teams to implement Continuous Delivery.
You will learn how to:
* Orchestrate Continuous Delivery pipelines with the new workflow feature,
* Scale Jenkins horizontally in your organization using Jenkins Operations Center by CloudBees,
* Implement end to end traceability with Jenkins and Puppet and Chef.
http://devops.com/news/ci-and-cd-across-enterprise-jenkins/
https://github.com/CloudBees-community/vagrant-puppet-petclinic
Vous n'avez pas pu assister à la journée DevOps by Xebia ? Voici la présentation de Cyrille Le Clerc (Cloudbees) et Geoffroy Warrin (Xebia) : "De l'intégration continue au déploiement continu avec Jenkins"
Flipkart.com is one of India's top 100 websites in terms of traffic. We use continuous deployment techniques to achieve quick deployments multiple times a day. Techniques and best practices we follow that we believe could be interesting to many others.
Jenkins and Chef: Infrastructure CI and Automated DeploymentDan Stine
This presentation discusses two key components of our deployment pipeline: Continuous integration of Chef code and automated deployment of Java applications. CI jobs for Chef code run static analysis and then provision, configure and test EC2 instances. Release jobs publish new cookbook versions to the Chef server. Deployment jobs identify target EC2 and VMware nodes and orchestrate Chef client runs. The flexibility of Jenkins is essential to our overall delivery architecture.
Deploying your Drupal site, Upgrading your Drupal Site, Scaling, Clustering and Monitoring it ... all topics Developers are often not involved with ...
Devops For Drupal explains the Devops problem, to a Drupal audience .
Introduction to Infrastructure as Code & Automation / Introduction to ChefNathen Harvey
Your customers expect you to continuously deliver delightful experiences. This means that you’ll need to continuously deliver application and infrastructure updates. Hand-crafted servers lovingly built and maintained by a system administrator are a thing of the past. Golden images are fine for initial provisioning but will quickly fail as your configuration requirements change over time.
It’s time for you to fully automate the provisioning and management of your infrastructure components. Welcome to the world of infrastructure as code! In this new world, you’ll be able to programmatically provision and configure the components of your infrastructure.
Disposable infrastructure whose provisioning, configuration, and on-going maintenance is fully automated allow you to change the way you build and deliver applications. Move your applications and infrastructure towards continuous delivery.
In this talk, we’ll explore the ideas behind “infrastructure as code” and, specifically, look at how Chef allows you to fully automate your infrastructure. If you’re brave enough, we’ll even let you get your hands on some Chef and experience the delight of using Chef to build and deploy some infrastructure components.
PuppetConf 2016: Continuous Delivery and DevOps with Jenkins and Puppet Enter...Puppet
Here are the slides fromCarl Caum and Brian Dawson's PuppetConf 2016 presentation called Continuous Delivery and DevOps with Jenkins and Puppet Enterprise. Watch the videos at https://www.youtube.com/playlist?list=PLV86BgbREluVjwwt-9UL8u2Uy8xnzpIqa
DevOps is a one-stop solution for all software engineering. From creating the software to implementing it in real-time, DevOps does all. This creates an infinite demand for excellent DevOps developers in the market. Since the platform is quite fast and effective, it is attracting the attention of many organizations that are looking to develop a software solution for their own business. Thus, here are a few DevOps interview questions that can help you crack an interview.
First Steps in Drupal Code Driven DevelopmentNuvole
"First Steps in Code Driven Development" covers basic techniques and good practices. Presented during the "Developer Session" at Krimson office, Antwerp (BE), the 27th of May 2010.
From Drupal 7 to Drupal 8 - Drupal Intensive Course OverviewItalo Mairo
From Drupal 7 to Drupal 8
A Drupal 7 and Drupal 8 course Intensive Overview
Treated arguments
Project characteristics
Main uses and users
Strength points
Community Documentation
Site Building Guide
Drupal 7 Focus
Implementation Workflow
Technology Stack, Core and Files Structure
Clean URLs & Aliases
Hooks
Themes
Blocks & Regions
Nodes
Taxonomy
Fields
Download & Extend (main useful modules)
Views Module
Menu System
Quality Assurance & Coding Standards
Multisite
Advanced Development Tools and Workflows
Git operational workflow
Continuous Integration, with Features Module
Drupal 8 Focus
Files Layout and Structures
Core concepts: “Proudly Invented Elsewhere”
New features and enhancements
WYSIWYG Editor
Quick Edit - In-place Editing
Refreshed Admin Theme
Draft Support in Core
Mobile First
Mobile-friendly Toolbar
Responsive-ize ALL Things (Themes, Images, Tables...)
Multilingual First & Language Selection Everywhere
Views in Core
More and Better Blocks
More Field Types
Render arrays
Front-end Developer Improvements
HTML5
Improved Accessibility
New Theme System: Twig
Back-end Developer Improvements
Symfony based Routing System
Configuration Management System & Configuration Sync Workflow
Content Deployment
Entities Everywhere, Configuration and Content Entities
Web Services
Improved Caching & Big Pipe
Building Modules with Drupal 8
Migration Path: Preparing for Drupal 8
Deciding When to Upgrade
Using Composer and GIT To create a new Drupal 8 project
Transform your Intranet with Drupal and Alfresco - by OptarosAlfresco Software
View the full webinar recording here: http://www.alfresco.com/about/events/ondemand
Learn how combining Drupal and Alfresco can give you a powerful platform with everything you need to revitalize your intranet with engaging community features, and rock-solid document management.
Optaros content management experts Chris Fuller and Jeff Potts will discuss how a game publisher was able to save time and money by leveraging open source for their intranet.
You’ll learn valuable insights that will help you take your Enterprise collaboration to the next level.
DevOps is not a one-trick pony. It involves a lot of changes to culture and attitudes. But the cultural changes only happen when you have the technology to enable it all. Oracle provides a comprehensive set of tools and products for traditional IT and cloud environments to help you deliver on your DevOps goals.
Choosing Drupal as your Content Management FrameworkMediacurrent
In Kendall Totten's presentation, "Choosing Drupal as a Content Management Framework for Your Next Project" she covered questions such as:
-What is Drupal and what makes it great?
-What is involved with building & theming a Drupal site?
-How to get a Drupal site off the ground quickly
-The difference between a base theme and a regular theme
-Modules that make theming easier
An introduction to Emulsify
In this presentation, Safallia Joseph of Valuebound has walked us through Emulsify -a component driven prototyping-tool using Pattern Lab. The various agendas include:
A brief intro to Components, Atomic Designs and Pattern Lab
How to get up and running with Pattern Lab in Drupal
An intro to Emulsify
Emulsify’s implementation of CDD
Getting started with Emulsify
Connecting Emulsify to Drupal
Benefits and challenges of a decoupled front end workflow in Drupal Projects
----------------------------------------------------------
Get Socialistic
Our website: http://valuebound.com/
LinkedIn: http://bit.ly/2eKgdux
Facebook: https://www.facebook.com/valuebound/
Twitter: http://bit.ly/2gFPTi8
A Reference Architecture to Enable Visibility and Traceability across the Ent...CollabNet
Software development should not be a “black box” to the business, customers or other developers. Instead collaboration across stakeholders should be the norm--business, development and operations teams. Forrester recently reported that 13% of organizations doing Agile link “upstream” agile planning with ‘“downstream” development.
As a result, executives continue to have only limited or no visibility beyond the initial planning stage of what is in a particular release. It’s not their fault, because today’s tools focus on upfront planning and don’t give you visibility into what’s happening in development. Often times that visibility is too late resulting in software that gets delivered and does not meet the customer’s needs.
Join CollabNet’s most experienced senior solution architects as they explain how you can you gain real time visibility into all stages of the development process—from ideation into production through deployment. Imagine what can your teams get done if all stakeholders are able to collaborate together and view real time feeds into all stages of the delivery pipelines within a single easy-to-use system.
Who Should attend:
Any executive or manager interested in learning how to get traceability and visibility across the enterprise-- particularly, into the build and release management functions of their application lifecycle.
What will be covered:
An enterprise-scalable reference architecture for CI, CD, and DevOps
The importance of build management, release management and application release automation integration
A blueprint for scaling business agility across a large development organization How does CollabNet help organizations solve these problems
A demonstration of TeamForge’s capabilities using Git/Gerrit, Code Review, Jenkins, Nexus, Artifactory, Chef and Automic
Elyra - a set of AI-centric extensions to JupyterLab Notebooks.Luciano Resende
In this session Luciano will explore the different projects that compose the Jupyter ecosystem; including Jupyter Notebooks, JupyterLab, JupyterHub and Jupyter Enterprise Gateway. Jupyter Notebooks are the current open standard for data science and AI model development, and IBM is dedicated to contributing to their success and adoption. Continuing the trend of building out the Jupyter ecosystem, Luciano will introduce Elyra. It's a project built to extend JupyterLab with AI-centric capabilities. He'll showcase the extensions that allow you to build Notebook Pipelines, execute notebooks as batch jobs, navigate and execute Python scripts, and tie neatly into Notebook versioning.
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Mack Hardy
Mack Hardy, Dave Tarc, Damien Norris of Affinity Bridge presenting at Pacific Northwest Drupal Summit in Vancouver, October 5th, 2013. The presentation walks through management of releases, deployment strategies and build strategies with drupal features, git, and make files. Performance and caching is also covered, as well as specific tips and tricks for configuring apache and managing private files.
Cloud and agile software projects: Overview and BenefitsGuillaume Berche
Slides from the session "Cloud and agile software projects: Overview and Benefits" at Agile Grenoble 2014, co presented by Guillaume Berche and Alain Delafosse.
http://agile-grenoble.org/
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerabilityAnn Lam
For the monthly Meetup Event on Nov. 8, we discussed the topic about the security issue of Drupal 7 and shared Drupal 8 preview (https://www.youtube.com/watch?v=ktCgVopf7D0). Enjoined the time with you all. Thanks for coming!!! Look forward to see you next time!
If you want to grow up as a DevOps developer you must have to know about these top 10 best DevOps tools in 2020 that will help you to boost your DevOps skills. check out these Top 10 Best Tools in 2020.
Italy Agriculture Equipment Market Outlook to 2027harveenkaur52
Agriculture and Animal Care
Ken Research has an expertise in Agriculture and Animal Care sector and offer vast collection of information related to all major aspects such as Agriculture equipment, Crop Protection, Seed, Agriculture Chemical, Fertilizers, Protected Cultivators, Palm Oil, Hybrid Seed, Animal Feed additives and many more.
Our continuous study and findings in agriculture sector provide better insights to companies dealing with related product and services, government and agriculture associations, researchers and students to well understand the present and expected scenario.
Our Animal care category provides solutions on Animal Healthcare and related products and services, including, animal feed additives, vaccination
This 7-second Brain Wave Ritual Attracts Money To You.!nirahealhty
Discover the power of a simple 7-second brain wave ritual that can attract wealth and abundance into your life. By tapping into specific brain frequencies, this technique helps you manifest financial success effortlessly. Ready to transform your financial future? Try this powerful ritual and start attracting money today!
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC
Ellisha Heppner, Grant Management Lead, presented an update on APNIC Foundation to the PNG DNS Forum held from 6 to 10 May, 2024 in Port Moresby, Papua New Guinea.
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfFlorence Consulting
Quattordicesimo Meetup di Milano, tenutosi a Milano il 23 Maggio 2024 dalle ore 17:00 alle ore 18:30 in presenza e da remoto.
Abbiamo parlato di come Axpo Italia S.p.A. ha ridotto il technical debt migrando le proprie APIs da Mule 3.9 a Mule 4.4 passando anche da on-premises a CloudHub 1.0.
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBrad Spiegel Macon GA
Brad Spiegel Macon GA’s journey exemplifies the profound impact that one individual can have on their community. Through his unwavering dedication to digital inclusion, he’s not only bridging the gap in Macon but also setting an example for others to follow.
5. Continuous Integration
“Continuous Integration” is a
software development practice
where members of a team
integrate work frequently,
usually each person integrates at
least daily - leading to multiple
integrations per day. Each
integration is verified by an
automated build (including
tests) to detect integration
errors as quickly as possible.
— Martin Fowler
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
6. Continuous Integration
• automating repetitive tasks such as build, QA and
deploy
• fast and frequent integrations
• fast feedback loop, catch errors asap
• ability to deploy quickly and keep track of every
released set of code
ADVANTAGES
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014-2015http://tenwarp.com/
7. Continuous Integration
developer
commits triggers
config
static
analysis
unit /
functional
tests
runs
runs
runs
report
FAIL
deploy
smoke /
functional
tests
report
SUCCESS
SUCCESS
FAIL
CI
server
revision
control
log
logs
logs
logs
BUILD PROCESS EXAMPLE
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
9. Continuous Integration
DRUPAL - I
Drupal, as opposed to “classic” frameworks such as
Symfony or Zend, does not make the setup and
maintenance a Continuous Integration cycle easy
due to the high coupling between data and
configuration within its database.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
10. Continuous Integration
DRUPAL - II
To overcome this problem it’s necessary to adopt a
strictly controlled, disciplined work methodology
and to make use of a set of tools that allow us to
transform configuration into code, to easily deal
with content and to incrementally update
database’s schema.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
11. Continuous Integration
WORKFLOW - I
A developer’s workflow consist not only in the plain
old features implementation, but also in the correct,
precise and complete export of all the element of
configuration that are necessary to rebuild the
functionalities on several environments.
!
Key modules: Features and Strongarm.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
12. Continuous Integration
WORKFLOW - II
It’s often necessary to setup some default content that
may vary during development and that might be
expanded or updated once the site has been
published. It’s therefore necessary to formalise in code
all the data import procedures in order to better
administrate them and to be able to replicate them at
any given time.
!
Key module: Migrate.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
13. Continuous Integration
WORKFLOW - III
As soon as a self-contained task such a bug-fix or a
new feature implementation has been completed,
it’s necessary to commit and push that unit of work
to the central repository in order to integrate, test
and deploy it automatically on the development
environment.
!
Key tools: git/svn.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
14. Continuous Integration
WORKFLOW - IV
!
Writing automated tests is necessary in order to
guarantee the behaviour of a given implementation
and to make sure that future changes won’t break
the work already done, creating regressions and
dealing potential damage to users and clients.
!
Key tools: PHPUnit, Behat.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
15. Q & A
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
16. Continuous Integration
EXERCISES
1. What are the main advantages of a Continuous Integration system?
2. When do Unit Tests are executed during the build? How about
functional? Why are they executed at different times?
3. Why is it important to write tests?
4. Which benefits come from using a Source Control Management system?
5. Why is Drupal so hard -compared to other tools such as “classic”
frameworks- to use in a Continuous Integration environment?
6. What tools allow Drupal to be successfully employed in a Continuous
Integration development cycle and for what reasons?
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
18. Phing is a build system written in PHP that allows
developers to describe the automated operations
used during development, deployment and
maintenance using plain XML files.
Phing
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
19. • Simplicity: it’s based on well-known, declarative XML syntax
and features a very rich documentation
• Power: thanks to the big amount of available tasks, it is able
to perform almost anything you could do using a
command line interpreter
• Extensibility: as it is written in PHP, it’s easy to extend and
debug
• Automation: the whole application configuration and
deployment process can be handled by build files
Phing
BENEFITS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
20. • execute tests and log their results
• perform filesystem operations
• interact with source configuration management systems
• generate documentation
• transfer files from/to remote systems
• fire drush commands
• invoke shell commands
Phing
FEATURES
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
21. There are two available file types in Phing to configure
the build: .properties and .xml files. The former
contains a list of key/value variables, while the latter
contains the “instructions” to execute.
In a usual setup there are up to five different
environments: loc, dev, stage, debug and prod. Each
of these ones will be configured using a
dedicated .properties file in order to make the build
file environment-agnostic so to reuse most of its code.
Phing
MAIN FILES AND ENVIRONMENTS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
23. Phing
BUILD FILE - PROJECT TAG
For every build file, there must be a single, unique,
root “project" tag. Within that "target", "task" and
“type" tags can be used.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
24. Phing
BUILD FILE - TYPE TAG
Besides default types such as numbers or strings, it is
possible to define more complex, nested types. An
interesting feature of Phing’s types is the ability to be
referenced by id later.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
25. Phing
BUILD FILE - TARGET TAG
“Targets” are collections of components that are
assigned a unique name within the project. It is possible
to invoke other targets within a target and it’s also
possible to set dependencies between different targets.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
26. Phing
BUILD FILE - TASK TAG
“Task”s are responsible for the execution of specific units
of work and are usually configurable through attributes
and nested tags. A few examples of what tasks do could
be: files copying, archive compression or drush
commands execution.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
27. Q & A
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
28. Phing
EXERCISES
1. What are the main benefits of using a build system?
2. Why is Phing more convenient than a bunch of shell
scripts?
3. What files does Phing use to work? What’s their
use?
4. What are the fundamental elements of a build file?
What’s their use?
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
30. Drush
Drush is a command-line shell and scripting
interface for Drupal, a veritable Swiss Army knife
designed to make life easier for those who spend
their working hours hacking away at the command
prompt.
— Drush Team
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
31. Drush
• Drupal Power: ability to simply, swiftly and
programmatically execute Drupal-specific tasks
• Integration: working with other command-line
tools is very easy and effective
BENEFITS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
32. Drush
• code and database backup, restore e sync
• cron tasks execution
• automatic installations
• variables, cache and logs CRUD operations
• modules and themes administration
• SQL commands execution
• users administration
• dependency management
• remote tasks execution
FEATURES
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
33. Drush
Drush make is a Drush extension that deals with
modules, themes, libraries and patches
management. It makes use of a manifest file to index
and download the required versions of the packages
used to build a Drupal website.
MAKE - I
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
34. Drush
MAKE - II
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
35. Drush
Drush Make allows developers to specify a
destination sub-folder using the “subdir” option.
We’ll leverage that to establish the convention of
having four sub-folders for modules: contrib,
custom, devel and features. This division will help in
keeping a cleaner division between the modules
and will save us the burden of versioning “contrib”
modules.
MAKE - III
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
36. Drush
Drush allows the developers to create a kind of
labels called Site Aliases: these are nothing but
configuration groups that fall under an arbitrary
name and make the execution of some Drush
commands easier. In our case those aliases match
the environments defined for our project, and will
look something like myproject.loc and
myproject.dev.
SITE ALIAS - I
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
37. Drush
SITE ALIAS - II
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
38. Drush
Drush looks for Aliases definitions in several locations:
1. in the path set in the “alias path” variable of the options array
found in the drushrc.php file
2. in the path specified in the —alias-path command-line option
3. in one of the following folders: “/etc/drush”, “$HOME/.drush” or
the current site’s “sites/all/drush”
In order to keep Drush Aliases clean and separated, we’ll use our
projects’ “sites/all/drush” as the go-to location to store their
configuration so not to pollute the global configuration.
SITE ALIAS - III
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
39. Drush
Drush implements two extremely useful commands
to keep files and databases in sync between hosts:
rsync e sql-sync.
• drush rsync @mysite.loc @mysite.dev
• drush sql-sync @mysite.loc @mysite.dev
SYNCHRONISATION
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
40. Q & A
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
41. Drush
EXERCISES
1. What’s Drush?
2. Why is it convenient to use it?
3. What are its most important features?
4. What’s the use for a make file?
5. What’s a Drush Site Alias? What’s its use?
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
43. Jenkins
Jenkins is a Java application useful to manage the
execution of those repetitive tasks that are needed
to build a software project.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
44. Jenkins
• automation of deployments procedures
• speed-up of repetitive tasks such as test runs or the
creation of build artifacts to deploy on our projects’
target environments
• logging and monitoring for a handful of code-related
stats such as test results or code quality analysis
• convenient web ui to configure all the needed jobs
BENEFITS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
45. Jenkins
FEATURES
• integration with several source configuration management
systems
• tests results and code quality reports generation
• integration with several build systems
• jobs status notifications
• configurable web ui
• hundreds of plugins
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
51. Q & A
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
52. Jenkins
ESERCIZI
1. What’s Jenkins?
2. What are its tasks?
3. What’s a Job?
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
54. Features
The Feature module is able to export parts of the
configuration found in the database into “ordinary”
Drupal modules. The ability to produce a set of files
containing a specific functionality starting from the
database makes them much easier to manage and
deploy across several systems and installations.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
55. • Removes the need for manual, repetitive work that’s necessary to
reproduce all of a website’s features and traits by encapsulating
them in portable, standard Drupal modules;
• Exports directly to Drupal modules or, in other words, text files:
that means it’s easy to version them using a source control
management system, which in turn makes easy to keep the history
of changes and allows multiple people to work on the project
concurrently;
• Allows to transport functionalities across websites in an easy,
reproducible and automatic fashion.
Features
BENEFITS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
60. Features
OPERATIONS - ENABLING A FEATURE
Enabling a Features-exported module executes the
same operations a “normal” module executes, such as:
• Schema installation;
• System Register and Cache update;
• Execution of hook_install();
• Execution of hook_enable().
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
61. Features
OPERATIONS - UPDATE & REVERT
Features Update: updating a feature
consists in the act of saving some of
the information found in the database
into a specific Feature Module.
Features Revert: reverting a
feature consists in the act of
writing the information found in a
Feature Module into the database.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
62. Features
features-components (fc) List features components.
features-diff (fd) Show the difference between the default
and overridden state of a feature.
features-export (fe) Export a feature from your site into a
module.
features-list (fl) List all the available features for your
site.
features-revert (fr) Revert a feature module on your site.
features-revert-all (fra) Revert all enabled feature module on
your site.
features-update (fu) Update a feature module on your site.
features-update-all (fua) Update all feature modules on your site.
DRUSH COMMANDS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
63. Features
• Thanks to the power and flexibility granted by the
Entity API it’s possible to easily create exportable
Entities that are automatically picked up and
handled by Features;
• A lot of contrib modules are already using such
possibility in order to provide exportable
configuration. Some examples could be the Rules,
Views or Context modules.
BEYOND THE DEFAULT OPTIONS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
64. Features
• Create and maintain “vertical” features such as blog, forum and front page. Avoid
creating Feature Modules that group “exportables” by type, such as “all site’s views” or
“all site’s rules”;
• Do always use English and specific namespaces when naming components
(field_blog_topics instead of field_argomenti);
• Do not use abbreviations unless it’s strictly ncssry.
• Keep a standard format when naming fields: try not to mix casing, dashing,
underscores and so on;
• Define conventions. The Kit Project, although abandoned, is a good source of
inspiration;
• Strive to keep things clean and in order: try to always use Features for importing and
exporting all the developed functionalities.
BEST PRACTICES
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
65. Q & A
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
66. Features
EXERCISES
1. What are the main goals of the Features module?
2. What components can it act upon?
3. What does feature-revert do?
4. What benefits does Features bring?
5. What’s Strongarm used for?
6. Can you name a few modules that allow their
components to be exported by Features?
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
68. Migrate
The Migrate module makes a powerful and flexible
object oriented framework for importing contents
into Drupal available to developers: it offers out-of-
the-box support for a handful of sources, such as
databases and file formats, and destinations, such as
nodes and taxonomy terms.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
69. Migrate
At macro-level, there’s four interesting areas to consider when
working with Migrate:
• An API for defining and managing the migration process;
• A set of Drush commands for managing the migrations, such as
import, rollback and status;
• An Admin UI featuring some of the features exposed by Drush;
• Some example modules that demonstrate a handful of
techniques used to define custom migrations.
FEATURES
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
71. Migrate
SOURCE
• Inherits from the abstract class
MigrateSource
• Provides an interface to the data set
• Iterates on the source’s rows
• Provides a list of fields
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
72. Migrate
DESTINATION
• Inherits from the abstract class MigrateDestination
(and usually from the more specific
MigrateDestinationEntity)
• Responsible for persisting data in a specific
Drupal’s content type such as user, node, comment,
file.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
73. Migrate
MAPPING TABLE
• Inherits from MigrateSQLMap, which in
turn inherits from the abstract class
MigrateMap
• Describes the key formats for the source
and the destination
• Stores all the information that’s used to
import and rollback each and every
single record
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
74. Migrate
FIELDS MAPPING
• Allows to link each destination field with a source
field
• Allows to transform data during the migration to
fix or adapt to the destination requirements.
• Allows to exclude some fields from the migration
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
75. Migrate
Handlers are classes that allow to execute additional
operations during the import process.
They are usually used to support migrations where
some specific, non-standard data is connected to
Core Entities: most of the time this will be related to
custom field types.
HANDLER
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
76. Migrate
There’s two kinds of Handler: Destination and Field.
The former is used to manipulate the Destination
Entity around saving (pre- and post- save) and to
declare additional fields exposed by the Destination
Entity.
The latter works much like the Destination Handler,
except its methods are invoked for each Field (as
opposed to each Entity).
HANDLER
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
77. Migrate
Sometimes there are pieces of content that hold
circular references to each other: for instance a
tutorial post “part 1” could contain a reference to the
“part 2” and vice-versa.
STUB
NODE
nid 1
title tutorial part I
body …
series_nids 2,3,4
NODE
nid 2
title tutorial part II
body …
series_nids 1,3,4
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
78. Migrate
During the import process the first node won’t be
able to correctly link to the second as the (new) id is
still unknown: Stubs solve this problem by creating
and linking a temporary, empty node that only holds
an id. As soon as the import process gets to the
stubbed node, it will populate it with all the due
information.
STUB
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
79. Migrate
Most of the time migrations are defined as static as that
source and the destination match one-to-one: one row,
one migration.
However, sometimes it’s necessary to “join” multiple
sources having the same structure into a single
destination: this kind of migration is defined as dynamic.
An example could be a migration where you need to
import users from several Drupal sites into a new one.
DYNAMIC MIGRATIONS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
80. Migrate
When using this functionality, Drupal will take care of
instantiating each migration multiple times. Besides that, a
dynamic migration differs from a static migration in the
following ways:
• its constructors accepts an array of arguments, where each
of its keys identifies an instance of the migration class;
• it overrides the generateMachineName() method in order
to generate a distinct machine name for each instance, so
to be able to identify them.
DYNAMIC MIGRATIONS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
81. Migrate
migrate-analyze (maz) Analyze the source fields for a migration.
migrate-audit (ma) View information on problems in a migration.
migrate-auto-register (mar) Register any newly-defined migration classes.
migrate-deregister Remove all tracking of a migration.
migrate-fields-destination (mfd) List the fields available for mapping in a destination.
migrate-fields-source (mfs) List the fields available for mapping from a source.
migrate-import (mi) Perform one or more migration processes.
migrate-mappings View information on all field mappings in a migration.
migrate-messages (mmsg) View any messages associated with a migration.
migrate-reset-status (mrs) Reset a active migration's status to idle.
migrate-rollback (mr) Roll back the destination objects from a given migration.
migrate-status (ms) List all migrations with current status.
migrate-stop (mst) Stop an active migration operation.
migrate-wipe (mw) Delete all nodes from specified content types.
DRUSH COMMANDS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
83. Migrate
• Migrate D2D - set of utilities for migrating content from
other versions of Drupal (5, 6, 7) to Drupal 7;
• Migrate Extras - integrates several contrib modules
such as Rules or Pathauto;
• Commerce Migrate - Integrates Drupal Commerce’s
Entities;
• Wordpress/Typo3/PHPBB Migrate - set of utilities to aid
the import of content from other well-known platforms.
BEYOND THE DEFAULT OPTIONS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
84. Q & A
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
85. Migrate
EXERCISES
1. What’s the main goal of the Migrate module?
2. What could be the sources for a migration?
3. What’s the use for the mapping table?
4. What does migrate-rollback do?
5. When is appropriate to use Migrate?
6. What’s a dynamic migration? How is it used?
7. What’s a stub?
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
87. Behat
Behat is a testing framework written in PHP with the
purpose of aiding the writing of Acceptance Tests
using Behaviour Driven Development practices.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
88. Behat
IT’S NOT A FUNCTIONAL
TESTING FRAMEWORK
It’s a tool to verify that a given
system satisfies the business
needs of the client.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
89. Behat
Tests are written using a semi-formal language
called Gherkin.
In a nutshell, Behat maps Gherkin sentences -usually
written in English, but it could be any language- to a
class method using to regular expressions.
GHERKIN
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
91. Behat
StoryBDD
Behaviour Driven Development based on User
Stories -aka StoryBDD- is a practice that helps into
bringing a development team’s understanding of
business requirements to the same level of the
client’s.
It does so by setting a formal process for asking
questions about requirements and then expressing
the outcome in a specific story-format.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
92. Behat
For each new feature, a developer should answer
the following business questions:
• Who will use it?
• What’s its purpose?
• How is that achieved?
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
StoryBDD
93. Behat
“I want users to access the site through a dedicated
form”
• Who will use it? a user an anonymous visitor
• What’s the purpose? it’s not stated
• How is that achieved? by using the login form
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
StoryBDD
94. “I want an anonymous visitor to be able to access the
site using the login form in order to access her
dashboard containing her aggregated data”
!
In order to see aggregated data on my dashboard
as a site visitor
I need to be able to login on the site
Behat
benefit
role
condition
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
StoryBDD
95. Once a feature is defined, you should start writing all
the scenarios that describe it, using the Context-
Action-Outcome pattern:
!
Given I am in on the homepage
When I login
Then I should see “Welcome Back!”
And I should be on my dashboard
Behat
SCENARIOS
context
action
outcome
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
97. Behat
BEST PRACTICES
And I should see “message” inside “.notifications > p:first-child”
!
It’s recommended to avoid technical details in your scenarios as they
increase the coupling between tests and code and make the stories
harder for non-technical readers -such as the client- to understand.
!
And I should see “message” inside notification area
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
98. Behat
MINK
Each test gets executed within a context where the
methods invoked by the expressions used in the scenarios
can access to a browser-abstraction API called Mink.
There are several drivers available for Mink such as Goutte,
a headless browser written in PHP that’s able to parse
HTML and XML and Selenium, a full-fledged framework
able to programmatically control real browsers.
Oh and there’s a Drush Driver, too! :)
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
100. Behat
MINK BEST PRACTICES
The Page object pattern is a way of keeping context files clean
by separating UI knowledge from the actions and assertions.
In other words, page objects hide the UI and expose clean
services that can be used in the context classes: such
abstraction makes context classes much more clear and helps
avoiding duplication and improving maintainability.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
103. Q & A
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
104. Behat
EXERCISES
1. What’s Behat and what’s its main goal?
2. What’s StoryBDD?
3. What’s a scenario?
4. What languages can be used to write the tests?
5. What questions should be answered by a feature description?
6. What are Mink’s main tasks?
7. What browsers can be used run the tests? What are the main
differences between them?
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
106. PHPUnit
PHPUnit is a unit testing framework, it’s part of xUnit
family and it has become the de-facto PHP standard
over the years.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
107. PHPUnit
In software engineering, unit testing is a method by
which individual units of code are tested to
determine if they are fit for use.
A unit is defined as the smallest part of an
application that can be tested in isolation: most of
the time that unit is a class or a method.
UNIT TESTING
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
108. PHPUnit
A SUT -an acronym for System Under Test- is defined
as that subset of the software being developed that’s
exercised by a test. It can be a specific method, and
object or even a set of objects.
DEFINITIONS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
109. PHPUnit
Writing automated tests (not necessarily unit tests only) sets some
goals:
• Improving the quality of the product and its code;
• Increasing developers’s understanding of the SUT;
• Decreasing the damage caused by unexpected bugs;
• Simplifying the creation, maintenance and execution of the tests;
• Documenting the behaviours of the applications’ components.
GOALS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
110. PHPUnit
TYPES OF TESTS
Unit
Integration
Functional
Functional: they operate on the
system from the outside, often by
simulating/employing a browser.
Integration: they check how
multiple components of the
system cooperate when
exercised together.
Unit: they make sure that the
single units of code behave as
expects when exercised in
isolation.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
111. PHPUnit
Should I test before or after development?
Traditionally tests -being them unitary or functional- have always
been executed once the implementation was completed.
Such approach has been upturned by the rise of agile
methodologies, where the emphasis is put on the ability to
respond to change quickly rather than sticking to a plan.
Writing tests first makes code inherently testable and therefore
safer to modify and usually produces less verbose and over-
engineered implementations.
METHODOLOGIES
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
112. PHPUnit
Should I test outside-in or inside-out?
As soon as development begins, a very important
decision has to be made: should it start from the big
picture and “zoom in” or from one or some of the
details and “zoom out” in order to compose the
macro-functionality at the end?
METHODOLOGIES
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
113. PHPUnit
Should I test outside-in or inside-out?
By starting development(and testing) from the outside, the
developer forces himself to think as a client first, a method that
helps in making requirements and (temporarily missing)
dependencies more explicit.
Developing “from the inside” on the other hand frees the
developer from the problem of not existing dependencies at
the cost of guessing what’s going to be the right set of things to
implement before reaching the requested level of functionality.
METHODOLOGIES
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
114. PHPUnit
Testing status or behaviour?
There are two main ways to verify the correctness of a SUT:
• Testing the state: it’s often sufficient to verify that given an initial
state, once the system is exercised the ending state then
matches the expected one.
• Testing the behaviour: it’s sometimes necessary to look inside
the black box of the SUT in order to check how the system works
during the execution of the tests to make sure all the behavioural
expectations were satisfied.
METHODOLOGIES
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
115. PHPUnit
TOOLS
PHPUnit provides a number of tools and helpers to aid testing, such as:
• Assertions
• Fixtures
• Database testing helpers
• Stub and mock objects
• Code coverage analysis tools
• Several logging formats
• Integration with several functional testing tools such as Selenium
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
117. PHPUnit
PHPUnit features about 80 assertions (of which 40 are
“straight” and 40 are “negated”). It’s up to the developer
to pick the best one for the test in order to have the most
expressive tests and the best error messages possible.
ASSERTIONS
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
118. PHPUnit
FIXTURES
When writing tests, one of the most tedious and time
consuming parts is the preparation of the environment
status before the actual execution happens: such status is
known as the fixture of the test .
PHPUnit features quite a big set of methods used to aid in
the creation and sharing of these states, such as:
setUpBeforeClass(), setUp(), assertPreConditions(),
assertPostConditions(), tearDown(), tearDownAfterClass()
and onNotSuccessfulTest(Exception $e).
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
119. PHPUnit
DATA PROVIDERS
It can be useful to be able to run
multiple iterations of the same
test on a larger-than-one data
set. Data Providers allows for a
convenient way to do just that.
Such providers are nothing but
a method that returns an array
containing all the combinations
of arguments a tests will be
called with.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
120. PHPUnit
TEST DOUBLES
It could be helpful -or necessary- to replace a SUT’s
dependencies with so-called “test doubles”, a kind of
objects that looks like the dependency but it’s
created with the sole purpose of satisfying testing
needs.
Such a replacement allows to isolate the SUT and
manipulate its inputs as needed, making the test
more effective and focused on the unit alone.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
121. PHPUnit
TEST DOUBLES
There are various kinds of Test Doubles, each serving a specific
purpose. Meszaros and Fowler suggested the following five
definitions:
• Dummy objects are passed around but never actually used.
Usually they are just used to fill parameter lists;
• Fake objects actually have working implementations, but
usually take some shortcut which makes them not suitable
for production (an InMemoryTestDatabase is a good
example);
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
122. PHPUnit
TEST DOUBLES
• Stubs provide canned answers to calls made during the test, usually
not responding at all to anything outside what's programmed in for
the test;
• Spies are stubs that also record some information based on how they
were called. One form of this might be an email service that records
how many messages it was sent;
• Mocks are pre-programmed with expectations which form a
specification of the calls they are expected to receive. They can throw
an exception if they receive a call they don't expect and are checked
during verification to ensure they got all the calls they were expecting.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
124. PHPUnit
OPTIONS
PHPUnit features a long list of options to configure its behaviour that’s
accessible both from command line and from a configuration file.
The former is a convenient way to quickly get started and try thing out,
but on the long run the phpunit.xml file is probably a more convenient
choice to configure the tool.
It’s a good practice to commit a phpunit.xml.dist file and (git) ignore the
phpunit.xml one: by doing such thing the other developers will be able
to create a phpunit.xml file tailored to their own needs.
PHPUnit will automatically use phpunit.xml if present or phpunit.xml.dist if
not.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
125. PHPUnit
OPTIONS BEST PRACTICES
It’s a good practice to commit a phpunit.xml.dist file
and (git) ignore the phpunit.xml one: by doing such
thing the other developers will be able to create a
phpunit.xml file tailored to their own needs, leaving
the phpunit.xml.dist targeted at automatic builds,
fore example.
PHPUnit is smart enough to automatically use
phpunit.xml if present or phpunit.xml.dist if not.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
127. PHPUnit
BEYOND THE DEFAULT OPTIONS
There are more tools provided by the community than what’s implemented
by PHPUnit alone. Here’s a short list of some relevant ones:
• Faker - a library that generates fake-yet-plausible data for a handful of
typical use cases such as names, addresses, numbers, dates, images, etc…
• Mockery - a powerful mocks creation library;
• Prophecy - a new, strongly-opinionated mocks creation library;
• PHP-VCR - a library to record and replay HTTP calls in tests;
• TuTu - a simple and flexible HTTP mocking tool.
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
128. Q & A
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/
129. PHPUnit
EXERCISES
1. What’s Unit Testing?
2. What are the main types of tests?
3. What are the benefits of writing the tests before the code?
4. What’s an assertion?
5. What’s a fixture?
6. What’s a data provider?
7. What’s the difference between a Stub and a Mock?
8. What’s the purpose of the phpunit.xml file?
Drupal Continuous Integration - By Claudio Beatrice - Copyright 2014http://tenwarp.com/