PHP Classes

How to Develop a PHP Unite Test Class to Test the features of a PHP Learning from the Example Package PHP Unit Testing Sample: Show how to test a class using PHPUnit

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-07-26 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 26 All time: 11,194 This week: 42Up
Version License PHP version Categories
php-unit-testing-sam 1.0.0The PHP License7Language, Testing, PHP 7
Description 

Author

This package can show how to test a class using PHPUnit.

It provides a simple class that models a user with a given name, age, and favorite color.

The package also provides a class that can test the features of the user class using the PHPUnit test case class.

This demonstrates how to perform php code unit testing using PHPUnit dependency

Picture of Okanlawon Anuoluwapo
  Performance   Level  
Name: Okanlawon Anuoluwapo <contact>
Classes: 6 packages by
Country: Nigeria Nigeria
Age: ???
All time rank: 350526 in Nigeria Nigeria
Week rank: 170 Up6 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 3x

Documentation

Test app sample

Writing php unit testing with phpunit

Run composer require to install all missing dependencies

Then, to test: run below line in terminal specifying the file-path or directory name:

    ./vendor/bin/phpunit

Example:

    ./vendor/bin/phpunit tests
    ./vendor/bin/phpunit tests/UserTest.php

  Files folder image Files (5)  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetests (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (5)  /  src  
File Role Description
  Plain text file User.php Class Class source

  Files folder image Files (5)  /  tests  
File Role Description
  Plain text file UserTest.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:26
This week:0
All time:11,194
This week:42Up