This document provides an overview of test driven development with PHPUnit. It discusses what unit testing is, the benefits of testing, and how to get started with PHPUnit. Key topics covered include writing tests, assertions, dependencies, data providers, testing errors and exceptions, fixtures, and database testing. The document also mentions test output, incomplete/skipped tests, test doubles, code coverage analysis, and the skeleton generator.
phpunit is testing framework for php testing.
A browser is able to give the syntax error but what if in case of some logical error.
Phpunit testing enables you to check your logic.
It is fully object oriented framework.
It also can be enabled in Netbeans.
you can find the option of phpunit testing in Netbeans
The presentation explains the PHP unit testing framework and provides a basic training on Testing with PHPunit. It Covers fundamental of unit testing, unit testing benefits and best practices. Starting ground up from PHP unit fundamentals, features of unit testing tries to explore advanced topics like Data providers, Fuxtures, Test doubles and more...
phpunit is testing framework for php testing.
A browser is able to give the syntax error but what if in case of some logical error.
Phpunit testing enables you to check your logic.
It is fully object oriented framework.
It also can be enabled in Netbeans.
you can find the option of phpunit testing in Netbeans
The presentation explains the PHP unit testing framework and provides a basic training on Testing with PHPunit. It Covers fundamental of unit testing, unit testing benefits and best practices. Starting ground up from PHP unit fundamentals, features of unit testing tries to explore advanced topics like Data providers, Fuxtures, Test doubles and more...
Aula 09 da disciplina de Programação Orientada a Objetos, ministrada pelo Departamento de Computação da Universidade Federal de Sergipe.
Apresenta os conceitos sobre herança.
Unit testing, everyone talks about it and wants to do it but never gets around to actually start testing. Complex spaghetti code and time / budget pressures are often the reasons why nobody dives in and gets started with testing. But when the application breaks, and people loose money or worse it's often too late.
In this talk I will take you on a journey with real examples that will show you how you can set up your tests, how to test complex situations with legacy spaghetti code, test web services, database interactions and how to gradually build a solid foundation to safeguard the core code base and everything around it.
Don't you want to be confident when you walk out the office?
Aula 09 da disciplina de Programação Orientada a Objetos, ministrada pelo Departamento de Computação da Universidade Federal de Sergipe.
Apresenta os conceitos sobre herança.
Unit testing, everyone talks about it and wants to do it but never gets around to actually start testing. Complex spaghetti code and time / budget pressures are often the reasons why nobody dives in and gets started with testing. But when the application breaks, and people loose money or worse it's often too late.
In this talk I will take you on a journey with real examples that will show you how you can set up your tests, how to test complex situations with legacy spaghetti code, test web services, database interactions and how to gradually build a solid foundation to safeguard the core code base and everything around it.
Don't you want to be confident when you walk out the office?
Testes de Performance na Nuvem | TDC2014Júlio de Lima
Nesta palestra serão apresentados alguns serviços na nuvem utilizados para testar o desempenho de aplicações web, uma forma mais barata de simular milhares de usuários virtuais usando a nuvem ao invés de criar ambientes complexos dentro do laboratório de testes de sua companhia.
No decorrer dos anos o teste de software tem evoluído e com isto
encontramos diversas ferramentas nos dias de hoje que nos ajudam a
entregar um serviço mais maduro e consolidado, uma destas ferramentas
é o Teste de Unidade (PHPUnit), na conversa o palestrante apresenta
alguns recursos para se utilizar junto com o PHPUnit e alguns exemplos
do uso do aplicativo.
IPC 2013 - High Performance PHP with HipHopSteve Kamerman
A look at Facebook's HipHop for PHP library, both the first generation, HPHPc, and the new HHVM. This presentation walks through the challenges that faced Facebook and their PHP-based solution from a year after their explosive growth in 2007 to late-2013.
Automated php unit testing in drupal 8Jay Friendly
An overview of PHPUnit Automated testing in Drupal 8, including a comparison of manual testing vs automated testing, the pros and cons of automated testing, and the types of automated tests available in Drupal 8.
Open-source projects often struggle with finding contributors and getting off of the ground. Communities, such as Github and PyPi, are host to redundant projects and libraries. In the development space, how do you distinguish your project from others, get people excited to contribute to it, and ultimately create a successful open source project? The answer is to apply user-centered design techniques to the development of your project. User-centered design is usually applied to web applications and products on the front-end of a website, but these techniques can be applied to open source libraries.
In this talk, Jackie will illustrate some user-centered techniques that have been used on her own project — Mesa (https://github.com/projectmesa/mesa), along with other successful open source projects. This talk will include a survey of interviews with a focus on successful techniques, along with additional user-centered design techniques that could be leveraged to inspire increased community engagement into your project.
The HTML5 history API is a standardized way to manipulate the browser history via script.The new parts in HTML5 include a way to add entries to the browser history, to visibly change the URL in the browser location bar (without triggering a page refresh), and an event that fires when those entries are removed from the stack by the user pressing the browser’s back button. This session would help learn more about HTML5 History API.
Fighting Fear-Driven-Development With PHPUnitJames Fuller
This talk was designed for PHP developers with limited or no experience in unit testing. I focus on describing the problem of fear-driven-development, and how test-driven-development can be used to improve the quality of your code.
This workshop is a hands-on training where a real Zend Framework application is used as an example to start improving QA using tools to test, document and perform software metric calculations to indicate where the software can be improved. I also explain the reports produced by a CI system.
Everyone talks about raising the bar on quality of code, but it's always hard to start implementing it when you have no clue where to start. With this talk I'm shooing that there are many levels developers can improve themselves by using the right tools. In this talk I'll go over each tool with examples how to use them against your codebase. A must attend talk for every developer that wants to scale up their quality. Most PHP developers deploy code that does what the customer requested but they don't have a clue about the quality of the product they deliver. Without this knowledge, maintenance can be a hell and very expensive. In this workshop I cover unit testing, code measuring, performance testing, debugging and profiling and give tips and tricks how to continue after this workshop.
Leveling Up With Unit Testing - php[tek] 2023Mark Niebergall
Writing unit testing on a project can seem like a daunting task, and earning team and leadership buy-in can be challenging. Level up your skillset as we cover PHPUnit and Prophecy setup with composer, writing meaningful tests, restructuring existing classes with dependency injection to allow for unit testing, using mock objects, and releasing code confidently with test coverage. We will also discuss overcoming common biases, unit testing challenges, and shortcomings of unit testing.
EPHPC Webinar
Unit Testing
Merangkak Menuju Pengembangan Aplikasi PHP yang Berkualitas dan Tahan Banting.
Date: Wednesday, April 6, 2011
Time: 1:00 pm, Bangkok Time (Bangkok, GMT+07:00)
Unlock The Mystery Of PHPUnit (Wave PHP 2018)ENDelt260
You know you're supposed to write unit tests, but you're not quite sure where to start. This session is for you. We will start from ground zero and go from zero unit test writing experience to functional test-driven developed code.
Using the current version of PHPUnit we will cover:
* writing basic test cases
* simple assertions and constraints
* mocking and data providers
* testing exceptions and errors
* and more!
You will leave this session fully ready to write tests for your own code.
Similar to Test Driven Development with PHPUnit (20)
This case study offers details of a project which involved developing an app to allow people to search for physicians/clinics in specified geographic areas. The app allows the users to rate and share reviews about the physicians they visit, and thus offer a reference point for people wanting to visit the same physicians in the future. For more details on our Health IT capabilities, visit: http://www.mindfiresolutions.com/healthcare.htm
The case study offers details of an app developed to enable its users to design healthy and personalized diet schedules, thus enabling them to keep their body weight under check. The app has features to offer customized solutions for the users. Progress can be monitored by referring to information shared in the form of charts and tables. For more details on other fitness/wellness apps developed by us, visit: http://www.mindfiresolutions.com/mHealth-development-services.htm
This casestudy elaborates on a cloud-based platform that we developed to enable enterprises to manage all their major business functions with outmost convenience – sales, internal efficiency, customer management. The platform offers them the capability to rapidly build web and mobile apps that can work together with built-in programs. For more details on our software development capabilities, visit: http://www.mindfiresolutions.com/
The casestudy offers details on an app developed to record and store readings made by three healthcare devices, which are used to measure healthcare vitals of users at remote locations. The App also has provision to generate different types to reports to facilitate subsequent analyses. For more details on our mHealth app development capabilities,
visit: http://www.mindfiresolutions.com/mHealth-development-services.htm
The project describes how a software platform can advance a very contemporary digital marketing technique of using Influencers to promote brands and services. For more details on our IT services, visit: http://www.mindfiresolutions.com/
This is all about details on High Availability of Applications running in Azure. Would cover on fundamentals of High Availability in Azure and discuss in depth on PaaS (High Availability of Web Role and Worker Role).
There was always embedded device in action, but the missing part was connectivity, intelligence, Knowledge from the data it was collecting. The Internet of Things is the new buzz word in trend. There will more embedded devices, more devices with sensor and more control on the physical process. Then we will see there are lots of thing surrounding us in near future. This is very initial phase of the IoT industry. But we have all the tools to experiment and make the things.
Oracle SQL Developer is an Integrated development environment (IDE) for working with SQL in Oracle databases.By the use of this, one can get an easy access to the Database, along with quick and effective SQL queries.
The introduction of Adaptive Layout in iOS 8 is a big paradigm shift for iOS app designers. When designing ones app, one can now create a single layout, which works on all current iOS 8 devices – without crafty platform-specific code!
Auto Layout is one of the most important system that lets one manage layout of ones application user interface. As we know, Apple supports different screen sizes in their devices, therefore managing application user interface becomes difficult.
LINQPad is a software utility targeted at Microsoft .NET development. It is used to interactively query SQL databases using LINQ.Some one planning to use this tool on the work front can refer to this presentation.
WatchKit is an API that extends Apple's development environment for iOS applications to allow apps / notifications to extend to the Apple Watch product. WatchKit is the Objective-C and Swift framework created by Apple to allow third-party developers to create apps for the Apple Watch ecosystem.
Objective-C is how we’ve built Mac and iOS apps for many years. It’s a huge part of the landscape of Apple Development. And, here comes Swift which is only a year old but with lot of promises and features.
Material Design can be simply explained as good design with the innovation and possibility of technology and science. In Material Design lot of new things were introduced like Material Theme, new widgets, custom shadows, vector drawable s and custom animations. This presentation is all about Material Design in Android.
This presentation is at the beginners level and mainly focusses on how to create and consume OData service in ASP.NET. OData (Open Data Protocol) is a standardized protocol for creating and consuming data APIs through regular HTTP requests and REST.
This presentation is about a basic Overview of Ext JS framework. Covers the discussion on topics like Understanding Ext JS API, Ext JS component Life cycle,Ext JS Components and Events and Ext JS Layouts etc.
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
CyanicLab, an offshore custom software development company based in Sweden,India, Finland, is your go-to partner for startup development and innovative web design solutions. Our expert team specializes in crafting cutting-edge software tailored to meet the unique needs of startups and established enterprises alike. From conceptualization to execution, we offer comprehensive services including web and mobile app development, UI/UX design, and ongoing software maintenance. Ready to elevate your business? Contact CyanicLab today and let us propel your vision to success with our top-notch IT solutions.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfJay Das
With the advent of artificial intelligence or AI tools, project management processes are undergoing a transformative shift. By using tools like ChatGPT, and Bard organizations can empower their leaders and managers to plan, execute, and monitor projects more effectively.
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
Keep tabs on your field staff effortlessly with Informap Technology Centre LLC. Real-time tracking, task assignment, and smart features for efficient management. Request a live demo today!
For more details, visit us : https://informapuae.com/field-staff-tracking/
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
As part of the DOE Integrated Research Infrastructure (IRI) program, NERSC at Lawrence Berkeley National Lab and ALCF at Argonne National Lab are working closely with General Atomics on accelerating the computing requirements of the DIII-D experiment. As part of the work the team is investigating ways to speedup the time to solution for many different parts of the DIII-D workflow including how they run jobs on HPC systems. One of these routes is looking at Globus Compute as a way to replace the current method for managing tasks and we describe a brief proof of concept showing how Globus Compute could help to schedule jobs and be a tool to connect compute at different facilities.
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
Traditional software testing methods are being challenged in retail, where customer expectations and technological advancements continually shape the landscape. Enter generative AI—a transformative subset of artificial intelligence technologies poised to revolutionize software testing.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Test Driven Development with PHPUnit
1. Test Driven Development with
PHPUnit
By: Kshirodra Meher
Software Engineer
Mindfire Solutions
2. Contents
Who am I ?
What & Why to do Testing ?
What is Unit testing ?
PHPUnit
Starting with PHPUnit
PHPUnit Example
Test Dependencies
Data Provider
Testing Error & Exceptions
Test Output
Assertion
Fixtures
Database Testing
Incomplete & Skipped Test
Test Doubles
Testing Practice
Code Coverage Analysis
Skeleton Generator & Selenium
Sources & Questions?
3. Who am I ?
Kshirodra Meher
PHP Developer,
Mindfire Solutions
(Aug-2011 to Present)
4. What & Why to do Testing ?
Testing : revealing a person's capabilities by putting them under strain;
challenging. :P
S/W Testing : Software testing is an investigation conducted to provide
stakeholders with information about the quality of the product or service
under test.
Why S/W Testing :
- Meet the requirements that guided its design and development
- Expected Results / Unexpected Failure
Software never was perfect and won’t get perfect. But is that a license
to create garbage? The missing ingredient is our reluctance to quantify
quality. – Boris Beizer
5. What is Unit Testing ?
Unit : The smallest testable code of an application
Test : Code that checks code on
If you don’t like unit testing your product, most likely your customers
won’t like to test it either.
Benefits :
- Changing/maintaining code
- Fixing cost is low
- Faster development etc etc .
6. Simple Test
Comparable to JUnit/PHPUnit
Created by Marcus Baker
Popular for testing web
pages at browser level
7. PHPUnit
PHPUnit is a programmer oriented testing framework for PHP
Part of xUnit family (JUnit, SUnit..)
Created By : Sebastian Bergmann
Integrated in most IDE :
- Eclipse, Netbeans, Zend Studio, PHPStorm
Integrated/Supported by :
- Zend Framework, Cake, Symfony
8. Starting with PHPUnit
PHPUnit can be installed using PEAR installer
Commands to install :
#pear config-set auto_discover 1
#pear install pear.phpunit.de/PHPUnit
9. Writing Tests for PHPUnit
The tests for a class Class go into a class ClassTest
ClassTest inherits(most of the time) from PHPUnit_Framework_TestCase
The tests are public methods that are named test*.
Inside the test methods, assertions methods such as assertEquals() are
used to assert that an actual value matches an expected value.
10. Lets do 'Hello World'
<?php
class HelloWorld {
public $helloWorld;
public function __construct($string = ‘Hello
World!’) {
$this->helloWorld = $string;
}
public function sayHello() {
return $this->helloWorld;
}
}
11. Test HelloWorld Class
require_once 'HelloWorld.php';
class HelloWorldTest extends PHPUnit_Framework_TestCase {
public function test__construct() {
$hw = new HelloWorld();
$this->assertInstanceOf('HelloWorld', $hw);
}
public function testSayHello() {
$hw = new HelloWorld();
$string = $hw->sayHello();
$this->assertEquals('Hello World!', $string);
}
}
13. PHPUnit Test Results Details
. - Printed when the test succeeds
F - Printed when an assertion fails while running the test method
E - Printed when an error occurs while running the test method
S - Printed when the test has been skipped
I - Printed when the test is marked as being incomplete or not yet
implemented
PHPUnit distinguishes between failures and errors. A failure is a violated
PHPUnit assertion such as a failing assertEquals() call. An error is an
unexpected exception or a PHP error. Sometimes this distinction proves
useful since errors tend to be easier to fix than failures.
14. Test Dependencies
PHPUnit supports the declaration of the explicit dependencies between test
methods. Such dependencies do not define the order in which the test
methods are to be executed but they allow the returning of an instance of the
test fixture by a producer and passing it to the dependent consumers.
A producer is a test method that yields its unit under test as return values.
A consumer is a test method that depends on one or more producers and
their return values.
Annotated by @depends
15. Data Provider
Test method can accept arbitrary arguments. These arguments are to be
provided by a data provider methods.
- Array
- Objects (that implements iterator)
Multiple arguments
Annotated by @dataProvider
16. Testing Error & Exceptions
PHPUnit converts PHP errors, warning, and notices that are triggered during
the execution of a test to an exception. Using these exceptions, you can, for
instance, expect a test to trigger a PHP error
Tests whether an exception is thrown inside the tested code.
Annotated by @expectedExceptions
17. Test Output
Sometimes you want to assert that the execution of a method, for instance,
generates an expected output via echo or print.
class OutputTest extends PHPUnit_Framework_TestCase {
public function testExpectFooActualFoo() {
$this->expectOutputString('foo');
print 'foo';
}
public function testExpectBarActualBaz() {
$this->expectOutputString('bar');
print 'baz';
}
}
20. Fixtures
Is a known state of an application
Need to be set up at the start of the test
Need to be torn down at the end of the test
Share states over the test methods
setUp() is where you create objects against which you will test
tearDown() is where you clean up the objects against which you tested
More setUp() then tearDown()
The setUpBeforeClass() and tearDownAfterClass() template methods are
called before the first test of the test case class is run and after the last test
of the case class is run, respectively
21. Database Testing
PHPUnit Database Extension
Can be installed by :
# pear install phpunit/DbUnit
Currently supported database :
- MySQL
- PostgreSQL
- Oracle
- SQLite
Has access to other database systems such as IBM DB2 / Microsoft SQL
Server through Zend Framework or Doctrine 2 integration
22. Database Testing
Four stages of database testing
- Setup fixture
- Exercise System Under Test
- Verify Outcome
- Teardown
(1. Clean-Up Database, 2. Set up fixture, 3–5. Run Test, Verify outcome and
Teardown)
Must implement
- getConnection() : Returns a database connection wrapper
- getDataSet() : Returns the dataset to seed the database with
24. Test Doubles
Introduced By : Gerard Meszaros
Replace a System Under Test (SUT) for the purpose of testing
Stubs
- Used for providing the tested code with "indirect input"
Mocks
- Used for verifying "indirect output" of the tested code, by first defining the
expectations before the tested code is executed
25. Testing Practices
Development
- All unit tests run correctly.
- The code communicates its design principles.
- The code contains no redundancies.
- The code contains the minimal number of classes and methods.
Debugging
- Verify that you can reproduce the defect.
- Find the smallest-scale demonstration of the defect in the code.
- Write an automated test that fails now but will succeed when the defect is
fixed.
- Fix the defect.
26. Code Coverage Analysis
How do you find code that is not yet tested or, in other words, not yet
covered by a test?
How do you measure testing completeness?
phpunit --coverage-html ./report BankAccountTest
27. Skeleton Generator & Selenium
PHPUnit Skeleton Generator is a tool that can generate skeleton test
classes from production code classes and vice versa.
pear install phpunit/PHPUnit_SkeletonGenerator
phpunit-skelgen --test Calculator
Selenium
- Is a test tool that allows you to write automated user-interface tests for web
applications in any programming language against any HTTP website using
any mainstream browser.