Build site

This commit is contained in:
Oliver Davies 2017-07-10 22:28:39 +01:00
parent 6f8d067847
commit 0c7de8559a
743 changed files with 92961 additions and 0 deletions

View file

@ -0,0 +1,280 @@
<!DOCTYPE html>
<html class="no-js" lang="en-GB">
<head>
<title>Fixing Drupal SimpleTest issues inside Docker Containers | Oliver Davies</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:url" content="https://www.oliverdavies.uk/blog/2017/05/05/fixing-drupal-simpletest-docker">
<meta property="og:title" content="Fixing Drupal SimpleTest issues inside Docker Containers"/>
<meta property="og:description" content="How I managed to get my Drupal SimpleTest tests to run and pass within Docker containers."/>
<meta property="og:image" content="https://www.oliverdavies.uk/assets/images/me-precedent.jpg"/>
<meta property="og:image:height" content="327"/>
<meta property="og:image:type" content="image/jpg">
<meta property="og:image:width" content="327"/>
<link rel="stylesheet" href="https://www.oliverdavies.uk/assets/css/main.css">
<link rel="stylesheet" href="https://www.oliverdavies.uk/assets/css/blog-post.css">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=57" sizes="57x57">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=114" sizes="114x114">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=72" sizes="72x72">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=144" sizes="144x144">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=60" sizes="60x60">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=120" sizes="120x120">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=76" sizes="76x76">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=152" sizes="152x152">
<link rel="icon" href="/assets/images/me-precedent.jpg?s=160" sizes="160x160">
<link rel="icon" href="/assets/images/me-precedent.jpg?s=96" sizes="96x96">
<link rel="icon" href="/assets/images/me-precedent.jpg?s=32" sizes="32x32">
<link rel="icon" href="/assets/images/me-precedent.jpg?s=16" sizes="16x16">
</head>
<body class="">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="https://www.oliverdavies.uk/">Oliver Davies</a>
</div>
<div id="navbar" class="collapse navbar-collapse" role="navigation">
<ul class="nav navbar-nav">
<li class="">
<a href="/">About</a>
</li>
<li class="">
<a href="/experience">Experience</a>
</li>
<li class="">
<a href="/testimonials">Testimonials</a>
</li>
<li class="">
<a href="/talks">Talks</a>
</li>
<li class="active">
<a href="/blog">Blog</a>
</li>
<li class="">
<a href="/contact">Contact</a>
</li>
</ul>
</div> </div>
</nav>
<div class="container">
<div class="row">
<main class="col-md-9">
<h1>Fixing Drupal SimpleTest issues inside Docker Containers</h1>
<p class="posted">5th May 2017</p>
<p><strong>TL;DR</strong> You need to include the name of your web server container as the <code>--url</code> option to <code>run-scripts.php</code>.</p>
<p>Ive been a <a href="https://www.drupalvm.com">Drupal VM</a> user for a long time, but lately Ive been using a combination Drupal VM and <a href="https://www.docker.com">Docker</a> for my local development environment. There were a couple of issues preventing me from completely switching to Docker - one of which being that when I tried running of my Simpletest tests, a lot of them would fail where they would pass when run within Drupal VM.</p>
<p>Heres an excerpt from my <code>docker-compose.yml</code> file:</p>
<pre><code class="language-yaml">services:
php:
image: wodby/drupal-php:5.6
volumes:
- ./repo:/var/www/html
nginx:
image: wodby/drupal-nginx:7-1.10
environment:
NGINX_BACKEND_HOST: php
NGINX_SERVER_ROOT: /var/www/html/web
ports:
- "80:80"
volumes_from:
- php
...
</code></pre>
<p>Nginx and PHP-FPM are running in separate containers, the volumes are shared across both and the Nginx backend is set to use the <code>php</code> container.</p>
<p>This is the command that I was using to run the tests:</p>
<pre><code class="language-bash">$ docker-compose run --rm \
-w /var/www/html/web \
php \
php scripts/run-tests.sh \
--php /usr/local/bin/php \
--class OverrideNodeOptionsTestCase
</code></pre>
<p>This creates a new instance of the <code>php</code> container, sets the working directory to my Drupal root and runs Drupals <code>run-tests.sh</code> script with some arguments. In this case, I'm running the <code>OverrideNodeOptionsTestCase</code> class for the override_node_options tests. Once complete, the container is deleted because of the <code>--rm</code> option.</p>
<p>This resulted in 60 of the 112 tests failing, whereas they all passed when run within a Drupal VM instance.</p>
<pre><code class="language-markup">Test summary
------------
Override node options 62 passes, 60 fails, 29 exceptions, and 17 debug messages
Test run duration: 2 min 25 sec
</code></pre>
<p>Running the tests again with the<code>--verbose</code> option, I saw this message appear in the output below some of the failing tests:</p>
<blockquote>
<p>simplexml_import_dom(): Invalid Nodetype to import</p>
</blockquote>
<p><strong>Update:</strong> I later found that <a href="https://www.drupal.org/docs/7/testing/running-tests-through-command-line#troubleshooting">https://www.drupal.org/docs/7/testing/running-tests-through-command-line#troubleshooting</a> references this error message, but I didnt see this page within my original search.</p>
<p>After checking that I had all of the required PHP extensions installed, I ran <code>docker-compose exec php bash</code> to connect to the <code>php</code> container and ran <code>curl http://localhost</code> to check the output. Rather than seeing the HTML for the site, I got this error message:</p>
<blockquote>
<p>curl: (7) Failed to connect to localhost port 80: Connection refused</p>
</blockquote>
<p>Whereas <code>curl http://nginx</code> returns the HTML for the page, so included it with the <code>--url</code> option to <code>run-tests.sh</code>, and this resulted in my tests all passing.</p>
<pre><code class="language-bash">$ docker-compose run --rm \
-w /var/www/html/web \
php \
php scripts/run-tests.sh \
--php /usr/local/bin/php \
--url http://nginx \
--class OverrideNodeOptionsTestCase
</code></pre>
<pre><code class="language-markup">Test summary
------------
Override node options 121 passes, 0 fails, 0 exceptions, and 34 debug messages
Test run duration: 2 min 31 sec
</code></pre>
<p><strong>Note:</strong> In this example I have separate <code>nginx</code> and <code>php</code> containers, but I've tried and had the same issue when running Nginx and PHP-FPM in the same container - e.g. called <code>app</code> - and still needed to add <code>--url http://app</code> in order for the tests to run successfully.</p>
<p>I dont know if this issue is macOS specfic (I know that <a href="https://www.drupal.org/drupalorg/docs/drupal-ci">Drupal CI</a> is based on Docker, and I dont know if its an issue) but Im going to test also on my Ubuntu Desktop environment and investigate further and also compare the test run times for Docker in macOS, Docker in Ubuntu and within Drupal VM. Im also going to test this with PHPUnit tests with Drupal 8.</p>
<p class="tags">
Tags:
<a href="https://www.oliverdavies.uk/blog/tags/docker">docker</a>, <a href="https://www.oliverdavies.uk/blog/tags/drupal">drupal</a>, <a href="https://www.oliverdavies.uk/blog/tags/drupal-planet">drupal-planet</a>, <a href="https://www.oliverdavies.uk/blog/tags/simpletest">simpletest</a>, <a href="https://www.oliverdavies.uk/blog/tags/testing">testing</a> </p>
<div class="post-pager is-flex">
<div class="is-half">
<a href="/blog/2017/01/31/nginx-redirects-with-query-string-arguments">
&laquo; Nginx Redirects With Query String Arguments
</a>
</div>
<div class="is-half text-right">
<a href="/blog/2017/05/15/drupalcamp-bristol-early-bird-tickets-sessions-sponsors">
DrupalCamp Bristol 2017 - Early Bird Tickets, Call for Sessions, Sponsors &raquo;
</a>
</div>
</div>
<div class="about-author">
<h2>About the Author</h2>
<img src="//images.oliverdavies.uk/assets/images/me-precedent.jpg" alt="Picture of Oliver" class="img-circle">
<p>Oliver Davies is a Web Developer, System Administrator and Drupal specialist based in the UK. He is a Senior Developer at <a href="https://microserve.io">Microserve</a> and also provides freelance consultancy services for Drupal websites, PHP applications and Linux servers.</p>
</div>
</main>
<div class="col-md-3">
<div class="panel badges text-center">
<a class="badge--da-member" href="https://assoc.drupal.org/membership" title="Im a Drupal Association member.">
<img
src="//images.oliverdavies.uk/assets/images/da-individual-member.png"
alt="Drupal Association Individual Member"
width="152"
>
</a>
<a href="http://drupalcores.com/#opdavies">
<img
alt="I built Drupal 8 with hand holding a wrench on blue background"
src="//images.oliverdavies.uk/assets/images/drupal-8.jpg"
/>
</a>
<img
src="//images.oliverdavies.uk/assets/images/badges/acquia-certified-developer-drupal-8.png"
alt="Acquia Certified Developer - Drupal 8 Exam Badge"
height="147" width="147"
/>
<a href="http://conference.phpnw.org.uk/phpnw17">
<img src="//images.oliverdavies.uk/assets/images/badges/phpnw17.png" alt="">
</a>
</div>
<div class="availability panel panel-default">
<div class="panel-heading">Availability</div>
<div class="panel-body">
<p>
<i class="fa fa-thumbs-o-up text-warning"></i>
Currently have limited part-time capacity
</p>
<p>
<i class="fa fa-thumbs-o-down text-danger"></i>
Currently no spare full-time capacity.
</p>
</div>
</div>
</div>
</div> </div>
<footer class="container">
<p class="copyright">
&copy; 2010-2017 Oliver Davies. Built with <a href="https://sculpin.io">Sculpin</a>.
</p>
<div class="meetups">
<h2>Things that I organise</h2>
<ul>
<li class="meetups--drupal-bristol">
<a href="http://www.drupalbristol.org.uk" title="Drupal Bristol">
<img src="//images.oliverdavies.uk/assets/images/meetups/drupal-bristol.jpeg" alt="Drupal Bristol">
</a>
</li>
<li class="meetups--drupalcamp-bristol">
<a href="http://www.drupalcampbristol.co.uk" title="DrupalCamp Bristol">
<img src="//images.oliverdavies.uk/assets/images/meetups/drupalcamp-bristol.png" alt="DrupalCamp Bristol">
</a>
</li>
<li class="meetups--phpsw">
<a href="http://phpsw.uk" title="PHPSW">
<img src="//images.oliverdavies.uk/assets/images/meetups/phpsw.jpeg" alt="PHPSW">
</a>
</li>
</ul>
</div>
</footer>
<script src="https://www.oliverdavies.uk/assets/js/site.js"></script>
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-11967257-1', 'auto'); ga('send', 'pageview');</script>
</body>
</html>

View file

@ -0,0 +1,2 @@
<!DOCTYPE html>
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><meta http-equiv="refresh" content="0;url=/blog/2017/05/05/fixing-drupal-simpletest-docker" /></head></html>

View file

@ -0,0 +1,217 @@
<!DOCTYPE html>
<html class="no-js" lang="en-GB">
<head>
<title>DrupalCamp Bristol 2017 - Early Bird Tickets, Call for Sessions, Sponsors | Oliver Davies</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:url" content="https://www.oliverdavies.uk/blog/2017/05/15/drupalcamp-bristol-early-bird-tickets-sessions-sponsors">
<meta property="og:title" content="DrupalCamp Bristol 2017 - Early Bird Tickets, Call for Sessions, Sponsors"/>
<meta property="og:type" content="website"/>
<meta property="og:image" content="https://www.oliverdavies.uk/assets/image/blog/drupalcamp-bristol-17-logo.jpg"/>
<meta property="og:image:type" content="image/jpg"/>
<meta property="og:image:width" content="448"/>
<meta property="og:image:height" content="228"/>
<link rel="stylesheet" href="https://www.oliverdavies.uk/assets/css/main.css">
<link rel="stylesheet" href="https://www.oliverdavies.uk/assets/css/blog-post.css">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=57" sizes="57x57">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=114" sizes="114x114">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=72" sizes="72x72">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=144" sizes="144x144">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=60" sizes="60x60">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=120" sizes="120x120">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=76" sizes="76x76">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=152" sizes="152x152">
<link rel="icon" href="/assets/images/me-precedent.jpg?s=160" sizes="160x160">
<link rel="icon" href="/assets/images/me-precedent.jpg?s=96" sizes="96x96">
<link rel="icon" href="/assets/images/me-precedent.jpg?s=32" sizes="32x32">
<link rel="icon" href="/assets/images/me-precedent.jpg?s=16" sizes="16x16">
</head>
<body class="">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="https://www.oliverdavies.uk/">Oliver Davies</a>
</div>
<div id="navbar" class="collapse navbar-collapse" role="navigation">
<ul class="nav navbar-nav">
<li class="">
<a href="/">About</a>
</li>
<li class="">
<a href="/experience">Experience</a>
</li>
<li class="">
<a href="/testimonials">Testimonials</a>
</li>
<li class="">
<a href="/talks">Talks</a>
</li>
<li class="active">
<a href="/blog">Blog</a>
</li>
<li class="">
<a href="/contact">Contact</a>
</li>
</ul>
</div> </div>
</nav>
<div class="container">
<div class="row">
<main class="col-md-9">
<h1>DrupalCamp Bristol 2017 - Early Bird Tickets, Call for Sessions, Sponsors</h1>
<p class="posted">15th May 2017</p>
<p><img src="/assets/images/blog/drupalcamp-bristol-17-logo.jpg" alt="DrupalCamp Bristol 2017 logo" class="is-centered"></p>
<p>In less than two months time, <a href="https://2017.drupalcampbristol.co.uk">DrupalCamp Bristol</a> will be back for our third year! (July seems to come around quicker each year). This is this years schedule and venues:</p>
<ul>
<li>30th June - CXO (Business) day - <a href="http://www.watershed.co.uk">Watershed</a></li>
<li>1st July - Developer conference - <a href="http://www.bris.ac.uk/chemistry">University of Bristol, School of Chemistry</a></li>
<li>2nd July - Contribution sprints - Venue TBC</li>
</ul>
<p>Today we announced <a href="http://emmakarayiannis.com">Emma Karayiannis</a> as our Saturday keynote speaker, and well be announcing some of the other speakers later this week.</p>
<p>Not submitted your session yet? The <a href="https://2017.drupalcampbristol.co.uk/#block-dcb2017-page-title">session submissions</a> are open until May 31st. Were looking for talks not only on Drupal, but other related topics such as PHP, Symfony, server administration/DevOps, project management, case studies, being human etc. If you want to submit but want to ask something beforehand, please <a href="&#109;&#x61;&#105;&#x6c;&#x74;&#111;&#x3a;&#115;&#112;&#x65;&#97;&#x6b;e&#114;&#x73;&#64;&#x64;r&#117;&#x70;&#97;&#x6c;&#x63;&#97;&#x6d;&#112;&#98;&#x72;&#105;&#x73;t&#111;&#x6c;&#46;&#x63;o&#46;&#x75;&#107;">send us an email</a> or ping us on <a href="https://twitter.com/DrupalCampBris">Twitter</a>.</p>
<p>Not spoken at a DrupalCamp before? No problem. Were looking for both new and experienced speakers, and have both long (45 minutes) and short (20 minutes) talk slots available.</p>
<p>Not bought your tickets yet? <a href="https://www.eventbrite.co.uk/e/drupalcamp-bristol-2017-tickets-33574193316#ticket">Early bird tickets</a> for the CXO and conference days are still available! The sprint day tickets are free but limited, so do register for a ticket to claim your place.</p>
<p>We still have <a href="https://2017.drupalcampbristol.co.uk/sponsorship">sponsorships opportunities</a> available (big thanks to <a href="https://microserve.io">Microserve</a>, <a href="https://www.deeson.co.uk">Deeson</a> and <a href="http://www.proctors.co.uk">Proctors</a>) who have already signed up), but be quick if you want to be included in our brochure so that we can get you added before our print deadline! Without our sponsors, putting on this event each year would not be possible.</p>
<p>Any other questions? Take a look at <a href="https://2017.drupalcampbristol.co.uk">our website</a> or get in touch via <a href="https://twitter.com/DrupalCampBris">Twitter</a> or <a href="m&#97;&#105;&#108;&#116;&#111;&#58;&#105;&#110;&#x66;&#x6f;&#x40;&#x64;&#x72;&#x75;&#x70;al&#99;&#97;&#109;&#112;&#98;&#114;&#105;&#x73;&#x74;&#x6f;&#x6c;&#x2e;&#x63;&#x6f;&#x2e;u&#107;">email</a>.</p>
<p class="tags">
Tags:
<a href="https://www.oliverdavies.uk/blog/tags/drupal">drupal</a>, <a href="https://www.oliverdavies.uk/blog/tags/drupal-planet">drupal-planet</a>, <a href="https://www.oliverdavies.uk/blog/tags/drupalcamp">drupalcamp</a>, <a href="https://www.oliverdavies.uk/blog/tags/drupalcamp-bristol">drupalcamp-bristol</a> </p>
<div class="post-pager is-flex">
<div class="is-half">
<a href="/blog/2017/05/05/fixing-drupal-simpletest-docker">
&laquo; Fixing Drupal SimpleTest issues inside Docker Containers
</a>
</div>
<div class="is-half text-right">
<a href="/blog/2017/05/20/turning-drupal-module-into-feature">
Turning Your Custom Drupal Module into a Feature &raquo;
</a>
</div>
</div>
<div class="about-author">
<h2>About the Author</h2>
<img src="//images.oliverdavies.uk/assets/images/me-precedent.jpg" alt="Picture of Oliver" class="img-circle">
<p>Oliver Davies is a Web Developer, System Administrator and Drupal specialist based in the UK. He is a Senior Developer at <a href="https://microserve.io">Microserve</a> and also provides freelance consultancy services for Drupal websites, PHP applications and Linux servers.</p>
</div>
</main>
<div class="col-md-3">
<div class="panel badges text-center">
<a class="badge--da-member" href="https://assoc.drupal.org/membership" title="Im a Drupal Association member.">
<img
src="//images.oliverdavies.uk/assets/images/da-individual-member.png"
alt="Drupal Association Individual Member"
width="152"
>
</a>
<a href="http://drupalcores.com/#opdavies">
<img
alt="I built Drupal 8 with hand holding a wrench on blue background"
src="//images.oliverdavies.uk/assets/images/drupal-8.jpg"
/>
</a>
<img
src="//images.oliverdavies.uk/assets/images/badges/acquia-certified-developer-drupal-8.png"
alt="Acquia Certified Developer - Drupal 8 Exam Badge"
height="147" width="147"
/>
<a href="http://conference.phpnw.org.uk/phpnw17">
<img src="//images.oliverdavies.uk/assets/images/badges/phpnw17.png" alt="">
</a>
</div>
<div class="availability panel panel-default">
<div class="panel-heading">Availability</div>
<div class="panel-body">
<p>
<i class="fa fa-thumbs-o-up text-warning"></i>
Currently have limited part-time capacity
</p>
<p>
<i class="fa fa-thumbs-o-down text-danger"></i>
Currently no spare full-time capacity.
</p>
</div>
</div>
</div>
</div> </div>
<footer class="container">
<p class="copyright">
&copy; 2010-2017 Oliver Davies. Built with <a href="https://sculpin.io">Sculpin</a>.
</p>
<div class="meetups">
<h2>Things that I organise</h2>
<ul>
<li class="meetups--drupal-bristol">
<a href="http://www.drupalbristol.org.uk" title="Drupal Bristol">
<img src="//images.oliverdavies.uk/assets/images/meetups/drupal-bristol.jpeg" alt="Drupal Bristol">
</a>
</li>
<li class="meetups--drupalcamp-bristol">
<a href="http://www.drupalcampbristol.co.uk" title="DrupalCamp Bristol">
<img src="//images.oliverdavies.uk/assets/images/meetups/drupalcamp-bristol.png" alt="DrupalCamp Bristol">
</a>
</li>
<li class="meetups--phpsw">
<a href="http://phpsw.uk" title="PHPSW">
<img src="//images.oliverdavies.uk/assets/images/meetups/phpsw.jpeg" alt="PHPSW">
</a>
</li>
</ul>
</div>
</footer>
<script src="https://www.oliverdavies.uk/assets/js/site.js"></script>
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-11967257-1', 'auto'); ga('send', 'pageview');</script>
</body>
</html>

View file

@ -0,0 +1,209 @@
<!DOCTYPE html>
<html class="no-js" lang="en-GB">
<head>
<title>Turning Your Custom Drupal Module into a Feature | Oliver Davies</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:url" content="https://www.oliverdavies.uk/blog/2017/05/20/turning-drupal-module-into-feature">
<meta property="og:title" content="Turning Your Custom Drupal Module into a Feature"/>
<meta property="og:image" content="https://www.oliverdavies.uk/assets/images/me-precedent.jpg"/>
<meta property="og:image:height" content="327"/>
<meta property="og:image:type" content="image/jpg">
<meta property="og:image:width" content="327"/>
<link rel="stylesheet" href="https://www.oliverdavies.uk/assets/css/main.css">
<link rel="stylesheet" href="https://www.oliverdavies.uk/assets/css/blog-post.css">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=57" sizes="57x57">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=114" sizes="114x114">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=72" sizes="72x72">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=144" sizes="144x144">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=60" sizes="60x60">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=120" sizes="120x120">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=76" sizes="76x76">
<link rel="apple-touch-icon" href="/assets/images/me-precedent.jpg?s=152" sizes="152x152">
<link rel="icon" href="/assets/images/me-precedent.jpg?s=160" sizes="160x160">
<link rel="icon" href="/assets/images/me-precedent.jpg?s=96" sizes="96x96">
<link rel="icon" href="/assets/images/me-precedent.jpg?s=32" sizes="32x32">
<link rel="icon" href="/assets/images/me-precedent.jpg?s=16" sizes="16x16">
</head>
<body class="">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="https://www.oliverdavies.uk/">Oliver Davies</a>
</div>
<div id="navbar" class="collapse navbar-collapse" role="navigation">
<ul class="nav navbar-nav">
<li class="">
<a href="/">About</a>
</li>
<li class="">
<a href="/experience">Experience</a>
</li>
<li class="">
<a href="/testimonials">Testimonials</a>
</li>
<li class="">
<a href="/talks">Talks</a>
</li>
<li class="active">
<a href="/blog">Blog</a>
</li>
<li class="">
<a href="/contact">Contact</a>
</li>
</ul>
</div> </div>
</nav>
<div class="container">
<div class="row">
<main class="col-md-9">
<h1>Turning Your Custom Drupal Module into a Feature</h1>
<p class="posted">20th May 2017</p>
<p>Yesterday I was fixing a bug in an inherited Drupal 7 custom module, and I decided that I was going to add some tests to ensure that the bug was fixed and doesnt get accidentially re-introduced in the future. The test though required me to have a particular content type and fields which are specific to this site, so werent present within the standard installation profile used to run tests.</p>
<p>I decided to convert the custom module into a <a href="https://www.drupal.org/project/features">Feature</a> so that the content type and its fields could be added to it, and therefore present on the testing site once the module is installed.</p>
<p>To do this, I needed to expose the module to the Features API.</p>
<p>All thats needed is to add this line to the <code>mymodule.info</code> file:</p>
<pre><code class="language-ini">features[features_api][] = api:2
</code></pre>
<p>After clearing the cache, the module is now visible in the Features list - and ready to have the appropriate configuration added to it.</p>
<p><img src="/assets/images/blog/custom-module-as-a-feature.png" alt="'The features list showing the custom module'" /></p>
<p class="tags">
Tags:
<a href="https://www.oliverdavies.uk/blog/tags/drupal">drupal</a>, <a href="https://www.oliverdavies.uk/blog/tags/drupal-7">drupal-7</a>, <a href="https://www.oliverdavies.uk/blog/tags/drupal-planet">drupal-planet</a>, <a href="https://www.oliverdavies.uk/blog/tags/features">features</a> </p>
<div class="post-pager is-flex">
<div class="is-half">
<a href="/blog/2017/05/15/drupalcamp-bristol-early-bird-tickets-sessions-sponsors">
&laquo; DrupalCamp Bristol 2017 - Early Bird Tickets, Call for Sessions, Sponsors
</a>
</div>
<div class="is-half text-right">
<a href="/blog/2017/06/09/introducing-the-drupal-meetups-twitterbot">
Introducing the Drupal Meetups Twitterbot &raquo;
</a>
</div>
</div>
<div class="about-author">
<h2>About the Author</h2>
<img src="//images.oliverdavies.uk/assets/images/me-precedent.jpg" alt="Picture of Oliver" class="img-circle">
<p>Oliver Davies is a Web Developer, System Administrator and Drupal specialist based in the UK. He is a Senior Developer at <a href="https://microserve.io">Microserve</a> and also provides freelance consultancy services for Drupal websites, PHP applications and Linux servers.</p>
</div>
</main>
<div class="col-md-3">
<div class="panel badges text-center">
<a class="badge--da-member" href="https://assoc.drupal.org/membership" title="Im a Drupal Association member.">
<img
src="//images.oliverdavies.uk/assets/images/da-individual-member.png"
alt="Drupal Association Individual Member"
width="152"
>
</a>
<a href="http://drupalcores.com/#opdavies">
<img
alt="I built Drupal 8 with hand holding a wrench on blue background"
src="//images.oliverdavies.uk/assets/images/drupal-8.jpg"
/>
</a>
<img
src="//images.oliverdavies.uk/assets/images/badges/acquia-certified-developer-drupal-8.png"
alt="Acquia Certified Developer - Drupal 8 Exam Badge"
height="147" width="147"
/>
<a href="http://conference.phpnw.org.uk/phpnw17">
<img src="//images.oliverdavies.uk/assets/images/badges/phpnw17.png" alt="">
</a>
</div>
<div class="availability panel panel-default">
<div class="panel-heading">Availability</div>
<div class="panel-body">
<p>
<i class="fa fa-thumbs-o-up text-warning"></i>
Currently have limited part-time capacity
</p>
<p>
<i class="fa fa-thumbs-o-down text-danger"></i>
Currently no spare full-time capacity.
</p>
</div>
</div>
</div>
</div> </div>
<footer class="container">
<p class="copyright">
&copy; 2010-2017 Oliver Davies. Built with <a href="https://sculpin.io">Sculpin</a>.
</p>
<div class="meetups">
<h2>Things that I organise</h2>
<ul>
<li class="meetups--drupal-bristol">
<a href="http://www.drupalbristol.org.uk" title="Drupal Bristol">
<img src="//images.oliverdavies.uk/assets/images/meetups/drupal-bristol.jpeg" alt="Drupal Bristol">
</a>
</li>
<li class="meetups--drupalcamp-bristol">
<a href="http://www.drupalcampbristol.co.uk" title="DrupalCamp Bristol">
<img src="//images.oliverdavies.uk/assets/images/meetups/drupalcamp-bristol.png" alt="DrupalCamp Bristol">
</a>
</li>
<li class="meetups--phpsw">
<a href="http://phpsw.uk" title="PHPSW">
<img src="//images.oliverdavies.uk/assets/images/meetups/phpsw.jpeg" alt="PHPSW">
</a>
</li>
</ul>
</div>
</footer>
<script src="https://www.oliverdavies.uk/assets/js/site.js"></script>
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-11967257-1', 'auto'); ga('send', 'pageview');</script>
</body>
</html>