PSpec is a testing framework for PHP, influenced by RSpec and jest. 🧪 This repo is a MIRROR of the GitLab source repository.

Overview

PSpec

PSpec is a testing framework for PHP, influenced by RSpec and jest.

This project is experimental and still needs a lot of work.

Example

// src/Counter.php
class Counter {
  public int $value = 0;

  function increment() {
    $this->value++;
  }
}

// spec/Counter.spec.php
describe(Counter::class, function () {
  subject(fn () => new Counter);

  let('base_value', 10);

  before(function () {
    subject()->value = $this->base_value;
  });

  describe('#increment', function () {
    it('increments by 1', function () {
      expect(subject()->value)->toBe($this->base_value);

      subject()->increment();

      expect(subject()->value)->toBe($this->base_value + 1);
    });
  });
});

Getting started

  1. Install PSpec: composer require --dev codingpaws/pspec
  2. In your project root, create a spec directory
  3. For a class in your project, for example Counter, create a file spec/Counter.spec.php
  4. Write some tests, like the example
  5. Run PSpec: vendor/bin/pspec

Why?

PSpec models your application with natural language. In PHPUnit—the de facto standard in PHP testing—a test file contains a sequential list of tests. If two tests are related in PHPUnit, such as one authenticated and one unauthenticated request, it’s hard to understand.

In PSpec, tests are nested under real-world conditions, such as being signed-in or when a network error occurs. You use describe blocks to organize tests.

Further reading

You might also like...
[READ-ONLY] CakePHP Utility classes such as Inflector, Text, Hash, Security and Xml. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Utility Classes This library provides a range of utility classes that are used throughout the CakePHP framework What's in the toolbox? Hash A

A Laravel test build by Incline Start-up Agency. Testing Git and framework functions.

Incognito-Confessions A laravel test build by Incline Start-up Agency. Testing Git and framework functions. Description A laravel starter for future t

Repo do vídeo do youtube de Design Patterns - Decorator
Repo do vídeo do youtube de Design Patterns - Decorator

DesignPatternsPHP-Decorator Repo do vídeo do Youtube de Design Patterns - Decorator Link do vídeo Decorator em PHP 8 Imagem de exemplo Link do cadastr

Repo for OSWE related video content for @SecAura Youtube Channel
Repo for OSWE related video content for @SecAura Youtube Channel

OSWE@SecAura A repository for related OSWE contents referenced in SecAura's YouTube Channel @SecAura SecAura Blog | PHP Web App 🔗 YouTube Playlist Li

Repo pour la Nuit de l'Info 2021, équipe Passage Python

Passage Python Repo pour la Nuit de l'Info 2021, équipe Passage Python Les membres de l'équipe sont : Florian Duzes, FloDarPie Theo Cavailles, igneefl

This Repo is a storage of Postman collections for Magento

Magento Postman repository This Repository is a storage of Postman collections for Magento. If you have what to share, you are welcome to contribute a

Quick package/plugin/component (repo) lookup for your favourite package managers
Quick package/plugin/component (repo) lookup for your favourite package managers

Package Managers (Download latest release) Package Repo Search Quick package/plugin/component (repo) lookup for your favourite package managers.

Buat yang lagi nyari web cafe yang simple untuk mengelola transaksi jual-beli mungkin repo ini tepat

Buat yang lagi nyari web cafe yang simple untuk mengelola transaksi jual-beli mungkin repo ini tepat. Aplikasi ini juga bisa digunakan buat kamu yang lagi belajar React Js dan REST API

Repository for the last open source version of Booked Scheduler.

Welcome to Booked Scheduler This is a community effort to keep the OpenSource GPLv3 BookedScheduler alive, see History Prerequisites PHP 7.0 or greate

Releases(v1.0)
  • v1.0(Jul 27, 2022)

    The first stable release of PSpec. The main goal from the start date onwards is to add tests and documentation but also a few more new matchers. This makes PSpec easy to get started with.

    Main updates

    • ✨ Making PSpec stable & easy to use
    • :wrench: Simple configuration
    • 📖 Docs on how to use PSpec: https://codingpaws.gitlab.io/pspec/

    Future plans

    • 🦾 Straightforward Laravel testing (see #32)
    • 📈 Improved coverage metrics (see #31)
    • :information_desk_person: More detailed, jest-like coverage report (see #64)
    • :rocket: Writing less tests with the same expessiveness (see #65)
    Source code(tar.gz)
    Source code(zip)
  • v0.1(Mar 31, 2022)

    PSpec

    PSpec is a testing framework for PHP, influenced by RSpec and jest.

    Example

    // src/Counter.php
    class Counter {
      public int $value = 0;
    
      function increment() {
        $this->value++;
      }
    }
    
    // spec/Counter.spec.php
    describe(Counter::class, function () {
      subject(fn () => new Counter);
    
      let('base_value', 10);
    
      before(function () {
        subject()->value = $this->base_value;
      });
    
      describe('#increment', function () {
        it('increments by 1', function () {
          expect(subject()->value)->toBe($this->base_value);
    
          subject()->increment();
    
          expect(subject()->value)->toBe($this->base_value + 1);
        });
      });
    });
    
    Source code(tar.gz)
    Source code(zip)
Owner
CodingPaws
Open-source projects by @KevSlashNull.
CodingPaws
Gitlab Composer repository

Gitlab Composer repository Small script that loops through all branches and tags of all projects in a Gitlab installation and if it contains a compose

WeMakeCustom -- DEFUNCT 165 Oct 17, 2022
This plugin allows you to display code from a repository, such as Github, Gitlab or others in order to use it as a resource in the courses.

Fetch Code This plugin allows you to display code from a repository, such as Github, Gitlab or others in order to use it as a resource in the courses.

Cambá Laboratorio de Tecnología 0 Dec 26, 2021
Mirror Laravel model inside Firestore collection.

Laravel Firestore Mirror This package can be used to store copy of Laravel model inside Firestore collection. Installation Install package: composer r

Firevel 5 Feb 27, 2022
Creates Packagist.org mirror site.

Packagist Mirror Creates your own packagist.org mirror site. Requirements PHP ^7.1.3 Installation Clone the repository Install dependencies: php compo

Indra Gunawan 32 Mar 30, 2020
🐋📦✂️📋📦 Docker image of packagist mirror

Docker for Packagist Mirror This project allows you to easily create and update a mirror of the packagist having as dependency only the docker. It is

Webysther Nunes 28 Jan 20, 2022
A PHP implementation of the Unleash protocol aka Feature Flags in GitLab.

A PHP implementation of the Unleash protocol aka Feature Flags in GitLab. This implementation conforms to the official Unleash standards and implement

Dominik Chrástecký 2 Aug 18, 2021
A Kimai 2 plugin, which send duration of cards to GitLab spend issues of timesheet.

GitLabBundle A Kimai 2 plugin, which send duration of cards to GitLab spend issues of timesheet. Installation First clone it to your Kimai installatio

LibreCode coop 9 Nov 14, 2022
Php-gamer - A repo with PHP 8.1, Swoole and Laminas. And of course, Docker in the front.

PHP-Gamer Instructions for run this app: First time $ git clone [email protected]:fatorx/php-gamer.git $ cd php-gamer $ chmod +x docker-build.sh $ chmod

Fabio de Souza 6 Oct 6, 2022
Private, self-hosted Composer/Satis repository with unlimited private and open-source packages and support for Git, Mercurial, and Subversion.

Private, self-hosted Composer/Satis repository with unlimited private and open-source packages and support for Git, Mercurial, and Subversion. HTTP API, HTTPs support, webhook handler, scheduled builds, Slack and HipChat integration.

Łukasz Lach 112 Nov 24, 2022
This is a Native PHP MVC. If you will build your own PHP project in MVC with router, you can clone this ready to use MVC pattern repo.

Welcome to PHP-Native-MVC-Pattern ?? If you will build your own PHP project in MVC with router, you can clone this ready to use MVC pattern repo. Work

null 2 Jun 6, 2022