Learning Yii Testing
eBook - ePub

Learning Yii Testing

Matteo Pescarin

Compartir libro
  1. 222 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Learning Yii Testing

Matteo Pescarin

Detalles del libro
Vista previa del libro
Índice
Citas

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Learning Yii Testing un PDF/ePUB en línea?
Sí, puedes acceder a Learning Yii Testing de Matteo Pescarin en formato PDF o ePUB, así como a otros libros populares de Ciencia de la computación y Programación web. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2015
ISBN
9781784392277

Learning Yii Testing


Table of Contents

Learning Yii Testing
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. The Testing Mindset
Understanding the importance of testing
Involving project management
Estimating tasks
Testing approaches
Introducing Test Driven Development
Planning tests
Generating tests
Obtaining the testing mindset
Starting with no testing culture – a practical approach
Summary
2. Tooling up for Testing
Downloading and installing Yii 2
Environment and workflow
Introducing Composer
Installing and using it
The composer.json and composer.lock files
Packages and Packagist
Creating your first web app
The CLI command line
Finding your way around Yii 2
Structure of the default web application
Documentation and sample code
Defining our working strategy
Key features to be implemented
User authentication REST interface
User login from a modal window
Introducing testing for our purposes
Using a top-down approach versus a bottom-up approach
What to test and what not to test
The master test plan
Summary
3. Entering Codeception
Getting started with Codeception
A modular framework rather than just another tool
Outlining concepts behind Codeception
Types of tests
AcceptanceTester
FunctionalTester
UnitTester
Other features provided by Codeception
Installing Codeception in Yii 2
Finding your way around Codeception
Configuring Codeception
Tests available in Yii 2
Interacting with Codeception
Creating tests
Migrations on the test database
Summary
4. Isolated Component Testing with PHPUnit
Understanding the work to be done
Using the User model
Implementing the first unit test
How much to care for other people's code
Component testing of the model
What's testing for PHPUnit
Testing the methods inherited by IdentityInterface
Using data providers for more flexibility
Using fixtures to prepare the database
Adding the remaining tests
Implementing the ActiveRecord class and its methods
Dealing with migrations
The Gii code generation tool
Seeing tests pass
Using global fixtures
Summary
5. Summoning the Test Doubles
Dealing with external dependencies
Isolating components with stubs
Listening for calls with an observer
Introducing mocking
Getting to know the Yii virtual attributes
Writing maintainable unit tests
Using BDD specification testing
Summary
6. Testing the API – PHPBrowser to the Rescue
Functional tests in Yii 2
Understanding and improving the available CEPTs
Writing reusable page interactions
Implementing fixtures
Pitfalls of functional tests
Functional tests for REST interfaces
Defining the API endpoints
Implementing the tests for the API
Creating a RESTful web service with Yii 2
Writing modular code in Yii
Creating a module with Gii
Using modules in Yii 2
Converting our controller to be a REST controller
Adding the access check and security layer
Building the authentication layer
Modifying the existing actions
Adding a new endpoint with parameters
Summary
7. Having Fun Doing Browser Testing
Introducing Selenium WebDriver
Installing and running Selenium Server
Configuring Yii to work with Selenium
Implementing WebDriver-led tests
Creating acceptance tests
Implementing the modal window
Making the server side work
Adding the JavaScript interaction
Tying everything together
Dealing with Yii 2 assets bundles
Finalizing the tests
Testing multiple browsers
Understanding Selenium limits
Summary
8. Analyzing Testing Information
Improving the quality of your tests
Enabling code coverage in Codeception
Extracting the code coverage information for unit tests
Generating a detailed coverage report of the unit tests
Aggregating functional tests to unit tests
Generating acceptance tests' coverage report
Improving our code with the aid of additional tools
Summary
9. Eliminating Stress with the Help of Automation
Automating the build process
Introducing continuous integration systems
Available systems
Installing and configuring Jenkins
Understanding the Jenkins organization
Installing the required plugins
Creating the required build files
Understanding the basic Ant structure
Adjusting the build.xml file
Preparing the environment for the build
Adding the required configuration settings
Adding Composer, Yii, and Codeception support in Ant
Configuring the Jenkins build
Generic build settings
Build settings
Postbuild settings
Executing the job
Going forward
Summary
Index

Learning Yii Testing

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: April 2015
Production reference: 1240415
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-227-7
www.packtpub.com

Credits

Author
Matteo Pescarin
Reviewers
Tristan Bendixen
Jesús Peña Cadena
Mark Katkov
Samuel Liew
Commissioning Editor
Akram Hussain
Acquisition Editors
James Jones
Greg Wild
Content Development Editor
Rahul Nair
Technical Editor
Taabish Khan
Copy Editors
Hiral Bhat
Tani Kothari
Vikrant Phadke
Sameen Siddiqui
Trishla Singh
Laxmi Subramanian
Project Coordinator
Suzanne Coutinho
Proofreaders
Stephen Copestake
Safis Editing
Indexer
Hemangini Bari
Production Coordinator
Komal Ramchandani
Cover Work
Komal Ramchandani

About the Author

Matteo Pescarin started his career as a filmsetter. He cofounded a digital agency in 1998 with Emanuele Tozzato and became an expert in Flash in 2001, giving talks and writing guides on it. He later decided to distance himself from closed source technologies and committed himself to open standards and open source, joining the Gentoo Channel Italia, an Italian-wide Linux User Group dedicated to the famous distro. He became passionate about HTML and XML-related semantic technologies, combining, once again, his passion for 2D graphics with programming.
Matteo moved to London, UK, in 2009 after getting a CS degree. While still working on LAMP technologies, he started learning and specializing on the project manag...

Índice