PHP Classes

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

Recommend this page to a friend!
  Info   View files Example   View files View files (53)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 62 All time: 10,385 This week: 150Up
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  
Name: Ogbemudia Osayawe <contact>
Classes: 8 packages by
Country: Germany Germany
Age: 40
All time rank: 2943174 in Germany Germany
Week rank: 312 Up18 in Germany Germany Up
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  
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

  Files folder image Files  /  Resources  
File Role Description
Files folder imagecss (1 file)
Files folder imagejs (1 file)

  Files folder image Files  /  Resources  /  css  
File Role Description
  Accessible without login Plain text file styles.css Data Auxiliary data

  Files folder image Files  /  Resources  /  js  
File Role Description
  Accessible without login Plain text file scripts.js Data Auxiliary data

  Files folder image Files  /  Src  
File Role Description
Files folder imageConfigs (2 files)
Files folder imageContracts (3 files)
Files folder imageDatabase (7 files)
Files folder imageEntity (2 files)
Files folder imageException (9 files)
Files folder imageHelpers (4 files)
Files folder imageLogger (2 files)
Files folder imageRepository (2 files)
  Accessible without login Plain text file add.php Example Example script
  Accessible without login Plain text file delete.php Example Example script
  Accessible without login Plain text file read.php Example Example script
  Accessible without login Plain text file update.php Example Example script

  Files folder image Files  /  Src  /  Configs  
File Role Description
  Accessible without login Plain text file app.php Aux. Auxiliary script
  Accessible without login Plain text file database.php Aux. Auxiliary script

  Files folder image Files  /  Src  /  Contracts  
File Role Description
  Plain text file DatabaseConnectionInterface.php Class Class source
  Plain text file LoggerInterface.php Class Class source
  Plain text file RepositoryInterface.php Class Class source

  Files folder image Files  /  Src  /  Database  
File Role Description
  Plain text file AbstractConnection.php Class Class source
  Plain text file MySQLiConnection.php Class Class source
  Plain text file MySQLiQueryBuilder.php Class Class source
  Plain text file PDOConnection.php Class Class source
  Plain text file PDOQueryBuilder.php Class Class source
  Plain text file Query.php Class Class source
  Plain text file QueryBuilder.php Class Class source

  Files folder image Files  /  Src  /  Entity  
File Role Description
  Plain text file BugReport.php Class Class source
  Plain text file Entity.php Class Class source

  Files folder image Files  /  Src  /  Exception  
File Role Description
  Plain text file BadRequestException.php Class Class source
  Plain text file BaseException.php Class Class source
  Plain text file DatabaseConnectionException.php Class Class source
  Accessible without login Plain text file exception.php Example Example script
  Plain text file ExceptionHandler.php Class Class source
  Plain text file InvalidArgumentException.php Class Class source
  Plain text file InvalidLogLevelArgument.php Class Class source
  Plain text file MissingArgumentException.php Class Class source
  Plain text file NotFoundException.php Class Class source

  Files folder image Files  /  Src  /  Helpers  
File Role Description
  Plain text file App.php Class Class source
  Plain text file Config.php Class Class source
  Plain text file DbQueryBuilderFactory.php Class Class source
  Plain text file HttpClient.php Class Class source

  Files folder image Files  /  Src  /  Logger  
File Role Description
  Plain text file Logger.php Class Class source
  Plain text file LogLevel.php Class Class source

  Files folder image Files  /  Src  /  Repository  
File Role Description
  Plain text file BugReportRepository.php Class Class source
  Plain text file Repository.php Class Class source

  Files folder image Files  /  Tests  
File Role Description
Files folder imageFunctional (2 files)
Files folder imageUnits (5 files)

  Files folder image Files  /  Tests  /  Functional  
File Role Description
  Plain text file CrudTest.php Class Class source
  Plain text file HomepageTest.php Class Class source

  Files folder image Files  /  Tests  /  Units  
File Role Description
  Plain text file ApplicationTest.php Class Class source
  Plain text file DatabaseConnectionTest.php Class Class source
  Plain text file LoggerTest.php Class Class source
  Plain text file QueryBuilderTest.php Class Class source
  Plain text file RepositoryTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:62
This week:0
All time:10,385
This week:150Up