SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
Tools and Tips for
Moodle Developers
Dan Poltawski
Integrator
Moodle HQ
@dan_p
the world’s open source learning platform
#mootus16
$CFG->debug = (E_ALL | E_STRICT); // DEBUG_DEVELOPER.
$CFG->debugdisplay = 1; // (unless you tail logs)
$CFG->cachejs = false; // But beware of browser cache!
$CFG->debugstringids = true; // With strings=1 url param.
$CFG->debugusers = ‘2,3,10’; // List of users ids
Debugging: config.php settings
the world’s open source learning platform
// Beginner.
echo "Course ID: $course->id”;
// Intermediate.
print_object($SESSION);
// Advanced.
debugging('a stack trace too!', DEBUG_DEVELOPER);
if ($CFG->debugdeveloper) {
echo '[..] some diagnostic code.';
}
// Wizard.
// (Uses xdebug and variable introspection)
Stages of Moodle printf() debugging (PHP)
the world’s open source learning platform
Stages of Moodle printf() debugging (JS)
// Beginner:
alert('courseid is: ' + course.id);
// Intermediate:
console.dir(course);
// Advanced:
Y.log('Info example in YUI module', 'info');
define(['core/log'], function(log) {
log.info('Info example from AMD Module.');
});
// Wizard:
// (uses web inspector, variable introspection)
the world’s open source learning platform
Performance debugging
the world’s open source learning platform
$CFG->perfdebug = 15; // First step.
xhprof
the world’s open source learning platform
xhprof
the world’s open source learning platform
the world’s open source learning platform
PHPUnit
Useful CLI Options
Filtering
vendor/bin/phpunit --filter block_online_users
vendor/bin/phpunit --testsuite block_online_users_testsuite
vendor/bin/phpunit blocks/online_users/tests/online_users_test.php
Coverage
vendor/bin/phpunit --coverage-html=coverage --filter block_online_users
PHPUnit
Test authoring tips:
• Use most specific assertion possible
• Make use of @dataProvider to
reduce duplication and get better
errors
• Remember we have data generators
to simplify setup code
/**
* Data provider for test_get_real_size().
*
* @return array An array of arrays contain test data
*/
public function data_for_test_get_real_size() {
return array(
array('8KB', 8192),
array('8G', 8589934592),
);
}
/**
* @dataProvider data_for_test_get_real_size
*/
public function test_get_real_size($input, $expectedbytes) {
$this->assertEquals($expectedbytes,get_real_size($input));
}
There was 1 failure:
1) core_setuplib_testcase::test_get_real_size with data set #0
('8KB', 8193)
Failed asserting that 8192 matches expected 8193.
the world’s open source learning platform
Behat
Useful CLI Options:
Filtering
—tags @block_online_users
—name “Add the online users on course
page and see other logged in users”
Rerun
—rerun
Profiles
—profile chrome
$CFG->behat_profiles = array(
'phantomjs' => array(
'browser' => ‘chrome’,
'wd_host' => ‘http://10.0.0.3:4444/wd/hub',
));
the world’s open source learning platform
Behat
Tips:
• Solutions for headless running:
• All platforms: Phantom JS
• Linux: Xvfb - X virtual framebuffer
• Mac: Fast user switching - with background user
• $x() in web developer console extremely useful for constructing
XPath queries
the world’s open source learning platform
Grunt
• grunt
• grunt watch
• grunt css
• grunt js
• grunt amd
• grunt yui
the world’s open source learning platform
• Analysing code for potential errors
• Good feedback loop
• Ensure consistency
• Integrate with your development workflow FTW!
Code Linting
the world’s open source learning platform
• Code-checker (local_codechecker)
• Available from Plugins Directory
• Uses PHP Code-sniffer underneath
• Integrations configured with path to local_codechecker/moodle/
location
Moodle Code Linters: PHP
the world’s open source learning platform
• ESLint
• New in Moodle 3.2 (MDL-52127), replaced jshint
• grunt js: checks for errors on AMD modules and YUI modules
• Integrations usually work without configuration ( eslintrc bundled)
Moodle Code Linters: Javascript
the world’s open source learning platform
• Packages: linter
• linter-phpcs
• linter-eslint
• Config:
"linter-phpcs":
codeStandardOrConfigFile: “/path/to/moodle-
Lint in your editor: Atom
the world’s open source learning platform
• Package: syntastic
• vimrc:
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_php_checkers = ['php', 'phpcs']
let g:syntastic_php_phpcs_args='--standard="/
path/to/moodle-local_codechecker/moodle/"'
Lint in your editor: vim
the world’s open source learning platform
Lint in your editor: PHPStorm
Configured in Editor > Inspections:
• PHP > PHP Code SnifferValidation
• Select ‘Custom’ coding standard and
choose path to local_codechecker/
moodle/
• Javascript > Code Quality Tools >
ESLint
the world’s open source learning platform
• SublimeLinter
• SublimeLinter-phpcs
• SublimeLinter-contrib-eslint
Sublime
"linters": {
"eslint": {
"@disable": false,
"args": [],
"excludes": []
},
"phpcs": {
"@disable": false,
"args": [],
"excludes": [],
"standard": “/path/to/moodle-local_codechecker/moodle/"
}}the world’s open source learning platform
Lint in your editor….
I’m sure their is an emacs integration too 🙄😘
the world’s open source learning platform
the world’s open source learning platform
“The goal of this project is to facilitate the running of
tests and code analysis tools against a Moodle plugin in
Travis CI.”
• https://github.com/moodlerooms/moodle-plugin-ci
• Created by Mark Nielsen (Moodlerooms)
• Extremely simple and comprehensive way to add CI to
your plugin
moodle-plugin-ci
the world’s open source learning platform
moodle-plugin-ci
the world’s open source learning platform
“A collection of tools meant to make developers' lives easier.”
• https://github.com/FMCorz/mdk
• Created by Frédéric Massart (Moodle HQ)
• Python tools - works with Linux and Mac
• (Windows patches welcomed!)
• Developed for core development tasks, but useful for non-core
work too
Moodle Development Kit (mdk)
• mdk create
• mdk upgrade
• mdk install
• mdk run
• mdk remove
MDK: Instance management
the world’s open source learning platform
• mdk phpunit
• init
• mdk behat
• init
• fail dumps
• seleneium server start
MDK: Testing
the world’s open source learning platform
• mdk fix
• mdk pull
• mdk push
MDK: Fixing issues
the world’s open source learning platform
• mdk fix
• mdk pull
• mdk push
MDK: Fixing continued
the world’s open source learning platform
the world’s open source learning platform
Email testing: config options
// Disable all Email.
$CFG->noemailever = true;
// Divert all outgoing emails to this address to test and debug emailing features
$CFG->divertallemailsto = 'youremail@example.com';
// Except for certain email addresses you want to let through for testing. Accepts
// a comma separated list of regexes.
$CFG->divertallemailsexcept = 'tester@dev.com, fred(+.*)?@example.com';
Email testing: mailcatcher
$CFG->smtphosts = 'localhost:1025';
$ gem install mailcatcher
$ mailcatcher
Starting MailCatcher
==> smtp://127.0.0.1:1025
==> http://127.0.0.1:1080
*** MailCatcher runs as a daemon by default.
Go to the web interface to quit.
the world’s open source learning platform
the world’s open source learning platform
Accessibility testing
• ChromeVox
• Chrome Extension - Quick and straight forward to get started
• Not JAWS but better than nothing
• Accessibility Developer Tools - Accessibility audit useful
git
• git log
• git blame
• git bisect
• https://github.com/dmonllao/who-broke-it
• git log --author=Damyon --grep="services"
the world’s open source learning platform
Questions?
@dan_p
the world’s open source learning platform

Weitere ähnliche Inhalte

Was ist angesagt?

How to learn to build your own PHP framework
How to learn to build your own PHP frameworkHow to learn to build your own PHP framework
How to learn to build your own PHP frameworkDinh Pham
 
Building Scalable IMS LTI Tools Using the TSUGI Framework
Building Scalable IMS LTI Tools Using the TSUGI FrameworkBuilding Scalable IMS LTI Tools Using the TSUGI Framework
Building Scalable IMS LTI Tools Using the TSUGI FrameworkCharles Severance
 
Introduction to building joomla! components using FOF
Introduction to building joomla! components using FOFIntroduction to building joomla! components using FOF
Introduction to building joomla! components using FOFTim Plummer
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppEdureka!
 
Drupal debugging tips
Drupal debugging tipsDrupal debugging tips
Drupal debugging tipsAdolfo Nasol
 
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)Mark Hamstra
 
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Mark Hamstra
 
MozTW Jetpack Workshop: Taipei
MozTW Jetpack Workshop: TaipeiMozTW Jetpack Workshop: Taipei
MozTW Jetpack Workshop: Taipeilittlebtc
 
Updated Version: Tsugi Overview
Updated Version: Tsugi OverviewUpdated Version: Tsugi Overview
Updated Version: Tsugi OverviewCharles Severance
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP ApplicationsPavan Kumar N
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentsparkfabrik
 
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)Mark Hamstra
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP TestingRan Mizrahi
 

Was ist angesagt? (20)

How to learn to build your own PHP framework
How to learn to build your own PHP frameworkHow to learn to build your own PHP framework
How to learn to build your own PHP framework
 
Building Scalable IMS LTI Tools Using the TSUGI Framework
Building Scalable IMS LTI Tools Using the TSUGI FrameworkBuilding Scalable IMS LTI Tools Using the TSUGI Framework
Building Scalable IMS LTI Tools Using the TSUGI Framework
 
Introduction to building joomla! components using FOF
Introduction to building joomla! components using FOFIntroduction to building joomla! components using FOF
Introduction to building joomla! components using FOF
 
Django
DjangoDjango
Django
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web App
 
Bootstrap4 x pages
Bootstrap4 x pagesBootstrap4 x pages
Bootstrap4 x pages
 
Tsugi Workshop @ Notre Dame
Tsugi Workshop @ Notre DameTsugi Workshop @ Notre Dame
Tsugi Workshop @ Notre Dame
 
How Browser Works?
How Browser Works?How Browser Works?
How Browser Works?
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Drupal debugging tips
Drupal debugging tipsDrupal debugging tips
Drupal debugging tips
 
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
 
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
 
Introduction to CakePHP
Introduction to CakePHPIntroduction to CakePHP
Introduction to CakePHP
 
Django Documentation
Django DocumentationDjango Documentation
Django Documentation
 
MozTW Jetpack Workshop: Taipei
MozTW Jetpack Workshop: TaipeiMozTW Jetpack Workshop: Taipei
MozTW Jetpack Workshop: Taipei
 
Updated Version: Tsugi Overview
Updated Version: Tsugi OverviewUpdated Version: Tsugi Overview
Updated Version: Tsugi Overview
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP Testing
 

Andere mochten auch

How integrators bring you a better Moodle
How integrators bring you a better MoodleHow integrators bring you a better Moodle
How integrators bring you a better MoodleDan Poltawski
 
Lifecycle of a Moodle Bug - #mootus16
Lifecycle of a Moodle Bug - #mootus16Lifecycle of a Moodle Bug - #mootus16
Lifecycle of a Moodle Bug - #mootus16Dan Poltawski
 
Continuous Integration: Improving Quality in Moodle
Continuous Integration: Improving Quality in Moodle Continuous Integration: Improving Quality in Moodle
Continuous Integration: Improving Quality in Moodle Dan Poltawski
 
Testing Moodle functionality automatically
Testing Moodle functionality automaticallyTesting Moodle functionality automatically
Testing Moodle functionality automaticallyDavid Monllaó
 
Moodle & Moodle Mobile 3.2 Release Party Barcelona
Moodle & Moodle Mobile 3.2 Release Party BarcelonaMoodle & Moodle Mobile 3.2 Release Party Barcelona
Moodle & Moodle Mobile 3.2 Release Party BarcelonaPau Ferrer Ocaña
 
Building a Moodle theme with bootstrap
Building a Moodle theme with bootstrapBuilding a Moodle theme with bootstrap
Building a Moodle theme with bootstrapBas Brands
 
A basic introduction to the Moodle architecture
A basic introduction to the Moodle architectureA basic introduction to the Moodle architecture
A basic introduction to the Moodle architectureTim Hunt
 
What is Moodle explained with Lego
What is Moodle explained with LegoWhat is Moodle explained with Lego
What is Moodle explained with LegoTomaz Lasic
 

Andere mochten auch (8)

How integrators bring you a better Moodle
How integrators bring you a better MoodleHow integrators bring you a better Moodle
How integrators bring you a better Moodle
 
Lifecycle of a Moodle Bug - #mootus16
Lifecycle of a Moodle Bug - #mootus16Lifecycle of a Moodle Bug - #mootus16
Lifecycle of a Moodle Bug - #mootus16
 
Continuous Integration: Improving Quality in Moodle
Continuous Integration: Improving Quality in Moodle Continuous Integration: Improving Quality in Moodle
Continuous Integration: Improving Quality in Moodle
 
Testing Moodle functionality automatically
Testing Moodle functionality automaticallyTesting Moodle functionality automatically
Testing Moodle functionality automatically
 
Moodle & Moodle Mobile 3.2 Release Party Barcelona
Moodle & Moodle Mobile 3.2 Release Party BarcelonaMoodle & Moodle Mobile 3.2 Release Party Barcelona
Moodle & Moodle Mobile 3.2 Release Party Barcelona
 
Building a Moodle theme with bootstrap
Building a Moodle theme with bootstrapBuilding a Moodle theme with bootstrap
Building a Moodle theme with bootstrap
 
A basic introduction to the Moodle architecture
A basic introduction to the Moodle architectureA basic introduction to the Moodle architecture
A basic introduction to the Moodle architecture
 
What is Moodle explained with Lego
What is Moodle explained with LegoWhat is Moodle explained with Lego
What is Moodle explained with Lego
 

Ähnlich wie Tools and Tips for Moodle Developers - #mootus16

modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet CampPuppet
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.jsChris Cowan
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Michelangelo van Dam
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applicationschartjes
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiRan Mizrahi
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...Puppet
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configurationlutter
 
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docxOrdering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docxhopeaustin33688
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache MesosJoe Stein
 
Auto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK NodesAuto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK Nodesnihiliad
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207patter
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebMikel Torres Ugarte
 
4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebookguoqing75
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolGordon Forsythe
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011camp_drupal_ua
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Michelangelo van Dam
 

Ähnlich wie Tools and Tips for Moodle Developers - #mootus16 (20)

modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Brad Wood - CommandBox CLI
Brad Wood - CommandBox CLI Brad Wood - CommandBox CLI
Brad Wood - CommandBox CLI
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configuration
 
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docxOrdering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache Mesos
 
Auto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK NodesAuto-loading of Drupal CCK Nodes
Auto-loading of Drupal CCK Nodes
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo Web
 
4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook4069180 Caching Performance Lessons From Facebook
4069180 Caching Performance Lessons From Facebook
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Drupal 8 migrate!
Drupal 8 migrate!Drupal 8 migrate!
Drupal 8 migrate!
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
 

Kürzlich hochgeladen

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Kürzlich hochgeladen (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Tools and Tips for Moodle Developers - #mootus16

  • 1. Tools and Tips for Moodle Developers Dan Poltawski Integrator Moodle HQ @dan_p the world’s open source learning platform #mootus16
  • 2. $CFG->debug = (E_ALL | E_STRICT); // DEBUG_DEVELOPER. $CFG->debugdisplay = 1; // (unless you tail logs) $CFG->cachejs = false; // But beware of browser cache! $CFG->debugstringids = true; // With strings=1 url param. $CFG->debugusers = ‘2,3,10’; // List of users ids Debugging: config.php settings the world’s open source learning platform
  • 3. // Beginner. echo "Course ID: $course->id”; // Intermediate. print_object($SESSION); // Advanced. debugging('a stack trace too!', DEBUG_DEVELOPER); if ($CFG->debugdeveloper) { echo '[..] some diagnostic code.'; } // Wizard. // (Uses xdebug and variable introspection) Stages of Moodle printf() debugging (PHP) the world’s open source learning platform
  • 4. Stages of Moodle printf() debugging (JS) // Beginner: alert('courseid is: ' + course.id); // Intermediate: console.dir(course); // Advanced: Y.log('Info example in YUI module', 'info'); define(['core/log'], function(log) { log.info('Info example from AMD Module.'); }); // Wizard: // (uses web inspector, variable introspection) the world’s open source learning platform
  • 5. Performance debugging the world’s open source learning platform $CFG->perfdebug = 15; // First step.
  • 6. xhprof the world’s open source learning platform
  • 7. xhprof the world’s open source learning platform
  • 8. the world’s open source learning platform PHPUnit Useful CLI Options Filtering vendor/bin/phpunit --filter block_online_users vendor/bin/phpunit --testsuite block_online_users_testsuite vendor/bin/phpunit blocks/online_users/tests/online_users_test.php Coverage vendor/bin/phpunit --coverage-html=coverage --filter block_online_users
  • 9. PHPUnit Test authoring tips: • Use most specific assertion possible • Make use of @dataProvider to reduce duplication and get better errors • Remember we have data generators to simplify setup code /** * Data provider for test_get_real_size(). * * @return array An array of arrays contain test data */ public function data_for_test_get_real_size() { return array( array('8KB', 8192), array('8G', 8589934592), ); } /** * @dataProvider data_for_test_get_real_size */ public function test_get_real_size($input, $expectedbytes) { $this->assertEquals($expectedbytes,get_real_size($input)); } There was 1 failure: 1) core_setuplib_testcase::test_get_real_size with data set #0 ('8KB', 8193) Failed asserting that 8192 matches expected 8193. the world’s open source learning platform
  • 10. Behat Useful CLI Options: Filtering —tags @block_online_users —name “Add the online users on course page and see other logged in users” Rerun —rerun Profiles —profile chrome $CFG->behat_profiles = array( 'phantomjs' => array( 'browser' => ‘chrome’, 'wd_host' => ‘http://10.0.0.3:4444/wd/hub', )); the world’s open source learning platform
  • 11. Behat Tips: • Solutions for headless running: • All platforms: Phantom JS • Linux: Xvfb - X virtual framebuffer • Mac: Fast user switching - with background user • $x() in web developer console extremely useful for constructing XPath queries the world’s open source learning platform
  • 12. Grunt • grunt • grunt watch • grunt css • grunt js • grunt amd • grunt yui the world’s open source learning platform
  • 13. • Analysing code for potential errors • Good feedback loop • Ensure consistency • Integrate with your development workflow FTW! Code Linting the world’s open source learning platform
  • 14. • Code-checker (local_codechecker) • Available from Plugins Directory • Uses PHP Code-sniffer underneath • Integrations configured with path to local_codechecker/moodle/ location Moodle Code Linters: PHP the world’s open source learning platform
  • 15. • ESLint • New in Moodle 3.2 (MDL-52127), replaced jshint • grunt js: checks for errors on AMD modules and YUI modules • Integrations usually work without configuration ( eslintrc bundled) Moodle Code Linters: Javascript the world’s open source learning platform
  • 16. • Packages: linter • linter-phpcs • linter-eslint • Config: "linter-phpcs": codeStandardOrConfigFile: “/path/to/moodle- Lint in your editor: Atom the world’s open source learning platform
  • 17. • Package: syntastic • vimrc: let g:syntastic_javascript_checkers = ['eslint'] let g:syntastic_php_checkers = ['php', 'phpcs'] let g:syntastic_php_phpcs_args='--standard="/ path/to/moodle-local_codechecker/moodle/"' Lint in your editor: vim the world’s open source learning platform
  • 18. Lint in your editor: PHPStorm Configured in Editor > Inspections: • PHP > PHP Code SnifferValidation • Select ‘Custom’ coding standard and choose path to local_codechecker/ moodle/ • Javascript > Code Quality Tools > ESLint the world’s open source learning platform
  • 19. • SublimeLinter • SublimeLinter-phpcs • SublimeLinter-contrib-eslint Sublime "linters": { "eslint": { "@disable": false, "args": [], "excludes": [] }, "phpcs": { "@disable": false, "args": [], "excludes": [], "standard": “/path/to/moodle-local_codechecker/moodle/" }}the world’s open source learning platform
  • 20. Lint in your editor…. I’m sure their is an emacs integration too 🙄😘 the world’s open source learning platform
  • 21. the world’s open source learning platform “The goal of this project is to facilitate the running of tests and code analysis tools against a Moodle plugin in Travis CI.” • https://github.com/moodlerooms/moodle-plugin-ci • Created by Mark Nielsen (Moodlerooms) • Extremely simple and comprehensive way to add CI to your plugin moodle-plugin-ci
  • 22. the world’s open source learning platform moodle-plugin-ci
  • 23. the world’s open source learning platform “A collection of tools meant to make developers' lives easier.” • https://github.com/FMCorz/mdk • Created by Frédéric Massart (Moodle HQ) • Python tools - works with Linux and Mac • (Windows patches welcomed!) • Developed for core development tasks, but useful for non-core work too Moodle Development Kit (mdk)
  • 24. • mdk create • mdk upgrade • mdk install • mdk run • mdk remove MDK: Instance management the world’s open source learning platform
  • 25. • mdk phpunit • init • mdk behat • init • fail dumps • seleneium server start MDK: Testing the world’s open source learning platform
  • 26. • mdk fix • mdk pull • mdk push MDK: Fixing issues the world’s open source learning platform
  • 27. • mdk fix • mdk pull • mdk push MDK: Fixing continued the world’s open source learning platform
  • 28. the world’s open source learning platform Email testing: config options // Disable all Email. $CFG->noemailever = true; // Divert all outgoing emails to this address to test and debug emailing features $CFG->divertallemailsto = 'youremail@example.com'; // Except for certain email addresses you want to let through for testing. Accepts // a comma separated list of regexes. $CFG->divertallemailsexcept = 'tester@dev.com, fred(+.*)?@example.com';
  • 29. Email testing: mailcatcher $CFG->smtphosts = 'localhost:1025'; $ gem install mailcatcher $ mailcatcher Starting MailCatcher ==> smtp://127.0.0.1:1025 ==> http://127.0.0.1:1080 *** MailCatcher runs as a daemon by default. Go to the web interface to quit. the world’s open source learning platform
  • 30. the world’s open source learning platform Accessibility testing • ChromeVox • Chrome Extension - Quick and straight forward to get started • Not JAWS but better than nothing • Accessibility Developer Tools - Accessibility audit useful
  • 31. git • git log • git blame • git bisect • https://github.com/dmonllao/who-broke-it • git log --author=Damyon --grep="services" the world’s open source learning platform
  • 32. Questions? @dan_p the world’s open source learning platform