Learning Yii Testing
eBook - ePub

Learning Yii Testing

Matteo Pescarin

Share book
  1. 222 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learning Yii Testing

Matteo Pescarin

Book details
Book preview
Table of contents
Citations

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Learning Yii Testing an online PDF/ePUB?
Yes, you can access Learning Yii Testing by Matteo Pescarin in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Programación web. We have over one million books available in our catalogue for you to explore.

Information

Year
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...

Table of contents