Testing

Yii 2 Testing

Testing Yii 2


Content of the «Testing» section The Definitive Guide to Yii 2.0:


Articles section «Testing» The Definitive Guide to Yii 2.0:

Fixtures in Yii 2

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Fixtures

Fixtures are an important part of testing. Their main purpose is to set up the environment in a fixed/known state so that your tests are repeatable and run in an expected way. Yii provides a fixture framework that allows you to define your fixtures precisely and use them easily both when running your tests with Codeception and independently.

Acceptance Tests Yii application

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Acceptance Tests

Acceptance test verifies scenarios from a user's perspective. The application tested is accessed via either PhpBrowser or a real browser. In both cases the browsers are communicating via HTTP so application should be served via web server.

Yii 2 Functional Tests

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Functional Tests

Functional test verifies scenarios from a user's perspective. It is similar to acceptance test but instead of communicating via HTTP it is filling up environment such as POST and GET parameters and then executes application instance right from the code.

Yii 2 Unit Tests

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Unit Tests

A unit test verifies that a single unit of code is working as expected. That is, given different input parameters, the test verifies the class method returns expected results. Unit tests are usually developed by people who write the classes being tested.

Yii 2 testing environment setup

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Testing environment setup

Yii 2 has officially maintained integration with Codeception testing framework that allows you to create the following test types:

  • Unit - verifies that a single unit of code is working as expected;
  • Functional - verifies scenarios from a user's perspective via browser emulation;
  • Acceptance - verifies scenarios from a user's perspective in a browser.

Yii 2 Testing Overview

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Testing

Testing is an important part of software development. Whether we are aware of it or not, we conduct testing continuously. For example, when we write a class in PHP, we may debug it step by step or simply use echo or die statements to verify the implementation works according to our initial plan. In the case of a web application, we're entering some test data in forms to ensure the page interacts with us as expected.