PHP Classes

PHP TDD Tutorial Bug Report Application: Bug report application to show the TDD approach

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 63 All time: 10,443 This week: 673Up
Version License PHP version Categories
php-oop-tdd 1.0.0MIT/X Consortium ...5PHP 5, Content management, Testing
Description 

Author

This package implements a bug report applications to show the TDD approach.

It implements classes for an application to record and view the bugs of a project in a database.

The package also comes with functional and unit test classes based on PHPUnit to verify if the application classes work as expected.

Innovation Award
PHP Programming Innovation award nominee
February 2022
Number 10
Test-Driven Design (TDD) is an approach to building software applications that create test code that will test the application code immediately after the developers write the application code.

This approach makes it easier to create applications that developers can verify if they comply with a given specification.

This package implements a sample application that demonstrates how to create a PHP application using the TDD approach.

Manuel Lemos
Picture of Ogbemudia Osayawe
  Performance   Level  
Innovation award
Innovation award
Nominee: 5x

 

Example

<?php declare( strict_types=1 );
require_once
__DIR__ . '/../vendor/autoload.php';

use
App\Entity\BugReport;
use
App\Repository\BugReportRepository;
use
App\Helpers\DbQueryBuilderFactory;
use
App\Database\QueryBuilder;
use
App\Logger\Logger;
use
App\Exception\BadRequestException;

if(isset(
$_POST, $_POST['add'])){
   
$reportType = $_POST['reportType'];
   
$email = $_POST['email'];
   
$link = $_POST['link'];
   
$message = $_POST['message'];

   
$bugReport = new BugReport;
   
$bugReport->setReportType($reportType);
   
$bugReport->setEmail($email);
   
$bugReport->setLink($link);
   
$bugReport->setMessage($message);

   
$logger = new Logger;
    try{
       
/** @var QueryBuilder $queryBuilder */
       
$queryBuilder = DbQueryBuilderFactory::make();
       
/** @var BugReportRepository $repository */
       
$repository = new BugReportRepository($queryBuilder);
       
/** @var BugReport $newReport */
       
$newReport = $repository->create($bugReport);
    }catch (
Throwable $exception){
       
$logger->critical($exception->getMessage(), $_POST);
        throw new
BadRequestException($exception->getMessage(), [$exception], 400);
    }

   
$logger->info(
       
'new bug report created',
        [
'id' => $newReport->getId(), 'type' => $newReport->getReportType(),]
    );
   
$bugReports = $repository->findAll();
}


Details

bug-report-app

Build A bug Tracking App with PHP OOP no Dependencies

Your support is needed, Enrol in Course.

Object Oriented PHP & TDD with PHPUnit from Scratch

As a PHP developer it won't take long to realize that there are dozens of outdated tutorials and articles on the internet, if you want to learn how to write better code, with fewer bugs, you will need to know how to write clean object oriented code and unit tests.

This course is designed to get you up and running as fast as possible with Test Driven Development with object oriented PHP and PHPUnit without any dependencies. We'll quickly cover OOP basics, then dive into some of the more advanced features of the language. Don't be tricked by other courses that only teach you basic and outdated stuffs!

This is the only course that will teach you Test Driven Development in Object Oriented PHP and PHPUnit. This course will give you ample opportunities to strike out on your own and start working on your own programs.

In this course you will:

Understand Object Oriented PHP

Learn test-driven development (TDD)

Learn how and why you should use dependency invasion principle and dependency injection

Implement some common design patterns using PHP

Build a database wrapper with support for PDO and MySQLi

Gain a sense of when to use basic language features

PHP is one of the most popular and widely used programming languages. Get job-ready with PHP today by enrolling now!


  Files folder image Files (53)  
File Role Description
Files folder imageResources (2 directories)
Files folder imageSrc (4 files, 8 directories)
Files folder imageTests (2 directories)
Accessible without login Plain text file addModal.php Aux. Auxiliary script
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 header.php Aux. Auxiliary script
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file store.sql Data Auxiliary data

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:63
This week:0
All time:10,443
This week:673Up