PHP Classes

How to Implement a PHP Testing Framework Using Different Testing Approaches Learning From the Package Dummy Stub Spy Mock: Demonstrate different types of PHP code tests

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-09-28 (2 days ago) RSS 2.0 feedNot enough user ratingsTotal: 7 This week: 7All time: 11,433 This week: 6Up
Version License PHP version Categories
dummy-stub-spy-mock 1.0The PHP License7Language, Testing, PHP 7
Description 

Author

This package can demonstrate different types of PHP code tests.

It provides several example classes, exceptions, and interfaces to show different approaches to test their implementation.

The package shows how to test the PHP code using dummies, stubs, and spy mocks.

Picture of DeGraciaMathieu
  Performance   Level  
Name: DeGraciaMathieu <contact>
Classes: 21 packages by
Country: France France
Innovation award
Innovation award
Nominee: 15x

Winner: 2x

Documentation

Dummy vs Stub vs Spy vs Mock

image

The "System under test" (SUT) refers to the class being tested.

  • Dummy: facilitates the instantiation of the SUT
  • Stub: manipulates the indirect inputs of the SUT
  • Spy and Mock: control and verify the indirect outputs of the SUT

Indirect inputs refer to the information that the SUT needs to function which cannot be supplied through its signature.

Indirect outputs refer to the information that cannot be verified through the signature provided.

image


  Files folder image Files (14)  
File Role Description
Files folder imagesrc (4 files)
Files folder imagetests (4 directories)
Accessible without login Plain text file readme.md Doc. Documentation

  Files folder image Files (14)  /  src  
File Role Description
  Plain text file BankConnectionException.php Class Class source
  Plain text file CashRegister.php Class Class source
  Plain text file Order.php Class Class source
  Plain text file Server.php Class Class source

  Files folder image Files (14)  /  tests  
File Role Description
Files folder imageDummy (2 files)
Files folder imageMock (2 files)
Files folder imageSpy (2 files)
Files folder imageStub (3 files)

  Files folder image Files (14)  /  tests  /  Dummy  
File Role Description
  Plain text file CashRegisterDummy.php Class Class source
  Plain text file DummyTest.php Class Class source

  Files folder image Files (14)  /  tests  /  Mock  
File Role Description
  Plain text file CashRegisterMock.php Class Class source
  Plain text file MockTest.php Class Class source

  Files folder image Files (14)  /  tests  /  Spy  
File Role Description
  Plain text file CashRegisterSpy.php Class Class source
  Plain text file SpyTest.php Class Class source

  Files folder image Files (14)  /  tests  /  Stub  
File Role Description
  Plain text file CashRegisterStub.php Class Class source
  Plain text file CashRegisterThatFa...ringPaymentStub.php Class Class source
  Plain text file StubTest.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:7
This week:7
All time:11,433
This week:6Up