Skip to content

Using the Specify trait via phar #6645

@feamsr00

Description

@feamsr00

What are you trying to achieve?

Using the Specify trait via phar

What do you get instead?

>codecept.phar run unit -vvv
Codeception PHP Testing Framework v4.2.2 https://helpukrainewin.org
Powered by PHPUnit 8.5.28 #StandWithUkraine
PHP Fatal error:  Trait "Codeception\Specify" not found in C:\dev\projects\code\tests\unit\API\BasicTest.php on line 2

Same test source code as the docs: https://codeception.com/docs/UnitTests#Specify

<?php
class UserTest extends \Codeception\Test\Unit
{
    use \Codeception\Specify;

    /** @specify */
    private $user;

    public function testValidation()
    {
        $this->user = User::create();

        $this->specify("username is required", function() {
            $this->user->username = null;
            $this->assertFalse($this->user->validate(['username']));
        });

        $this->specify("username is too long", function() {
            $this->user->username = 'toolooooongnaaaaaaameeee';
            $this->assertFalse($this->user->validate(['username']));
        });

        $this->specify("username is ok", function() {
            $this->user->username = 'davert';
            $this->assertTrue($this->user->validate(['username']));
        });
    }
}

Details

  • Codeception version: 4.2.2
  • PHP Version: 8.1.11
  • Operating System: Win 10.0.19045.2604
  • Installation type: Phar
List of installed packages (`composer show`) ```bash clue/stream-filter v1.6.0 A simple and modern approach to stream filtering in PHP composer/pcre 3.1.0 PCRE wrapping library that offers type-safe preg_* replacements. composer/semver 3.3.2 Semver library that offers utilities, version constraint parsing and validation. composer/xdebug-handler 3.0.3 Restarts a process without Xdebug. doctrine/annotations 1.14.2 Docblock Annotations Parser doctrine/deprecations v1.0.0 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages. doctrine/inflector 2.0.6 PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words. doctrine/lexer 2.1.0 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers. friendsofphp/php-cs-fixer v3.13.1 A tool to automatically fix PHP code style guzzlehttp/guzzle 6.5.8 Guzzle is a PHP HTTP client library guzzlehttp/promises 1.5.2 Guzzle promises library guzzlehttp/psr7 1.9.0 PSR-7 message implementation that also provides common utility methods http-interop/http-factory-guzzle 1.2.0 An HTTP Factory using Guzzle PSR7 jane-php/json-schema v7.4.0 Generate a serializable / deserializable object model given a json schema jane-php/json-schema-runtime v7.4.0 Jane runtime Library jane-php/open-api-3 v7.4.0 Generate a PHP Client API (PSR7/PSR18 compatible) given a OpenApi 3.x specification jane-php/open-api-common v7.4.0 Utility for OpenApi 2/3 generators jane-php/open-api-runtime v7.4.0 Jane OpenAPI Runtime Library, dependencies and utility class for a library generated by jane/openapi league/uri 6.8.0 URI manipulation library league/uri-interfaces 2.3.0 Common interface for URI representation monolog/monolog 3.2.0 Sends your logs to files, sockets, inboxes, databases and various web services nikic/php-parser v4.15.2 A PHP parser written in PHP phing/phing 2.17.4 PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant. php-http/client-common 2.6.0 Common HTTP Client implementations and tools for HTTPlug php-http/discovery 1.14.3 Finds installed HTTPlug implementations and PSR-7 message factories php-http/guzzle6-adapter v2.0.2 Guzzle 6 HTTP Adapter php-http/httplug 2.3.0 HTTPlug, the HTTP client abstraction for PHP php-http/logger-plugin 1.3.0 PSR-3 Logger plugin for HTTPlug php-http/message 1.13.0 HTTP Message related tools php-http/message-factory v1.0.2 Factory interfaces for PSR-7 HTTP Message php-http/mock-client 1.5.0 Mock HTTP client php-http/multipart-stream-builder 1.2.0 A builder class that help you create a multipart stream php-http/promise 1.1.0 Promise used for asynchronous HTTP requests php-jsonpointer/php-jsonpointer v3.0.2 Implementation of JSON Pointer (http://tools.ietf.org/html/rfc6901) psr/cache 3.0.0 Common interface for caching libraries psr/container 2.0.2 Common Container Interface (PHP FIG PSR-11) psr/event-dispatcher 1.0.0 Standard interfaces for event handling. psr/http-client 1.0.1 Common interface for HTTP clients psr/http-factory 1.0.1 Common interfaces for PSR-7 HTTP message factories psr/http-message 1.0.1 Common interface for HTTP messages psr/log 3.0.0 Common interface for logging libraries ralouphie/getallheaders 3.0.3 A polyfill for getallheaders. sebastian/diff 4.0.4 Diff implementation symfony/console v6.2.3 Eases the creation of beautiful and testable command line interfaces symfony/deprecation-contracts v3.2.0 A generic function and convention to trigger deprecation notices symfony/event-dispatcher v6.2.2 Provides tools that allow your application components to communicate with each other by dispatching events and listening to them symfony/event-dispatcher-contracts v3.2.0 Generic abstractions related to dispatching event symfony/filesystem v6.2.0 Provides basic utilities for the filesystem symfony/finder v6.2.3 Finds files and directories via an intuitive fluent interface symfony/options-resolver v6.2.0 Provides an improved replacement for the array_replace PHP function symfony/polyfill-ctype v1.27.0 Symfony polyfill for ctype functions symfony/polyfill-intl-grapheme v1.27.0 Symfony polyfill for intl's grapheme_* functions symfony/polyfill-intl-idn v1.27.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions symfony/polyfill-intl-normalizer v1.27.0 Symfony polyfill for intl's Normalizer class and related functions symfony/polyfill-mbstring v1.27.0 Symfony polyfill for the Mbstring extension symfony/polyfill-php72 v1.27.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions symfony/polyfill-php73 v1.27.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions symfony/polyfill-php80 v1.27.0 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions symfony/polyfill-php81 v1.27.0 Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions symfony/process v6.2.0 Executes commands in sub-processes symfony/serializer v6.2.3 Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON. symfony/service-contracts v3.2.0 Generic abstractions related to writing services symfony/stopwatch v6.2.0 Provides a way to profile code symfony/string v6.2.2 Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way symfony/translation-contracts v3.2.0 Generic abstractions related to translation symfony/validator v6.2.3 Provides tools to validate values symfony/var-dumper v6.2.3 Provides mechanisms for walking through any arbitrary PHP variable symfony/yaml v6.2.2 Loads and dumps YAML files ```
  • Suite configuration:
# Codeception Test Suite Configuration
#
# Suite for unit or integration tests.

actor: UnitTester
modules:
    enabled:
        - Asserts
        - \Helper\Unit
    step_decorators: ~

If I understand correctly, according to https://github.com/Codeception/codeception.github.com/blob/master/package/composer.json codeception/specify was never included in the phar's composer to begin with? The docs on this page however clearly state that it should be:

For this case we have a stand-alone project Specify (which is included in the phar package) for writing specifications inside unit tests:

Bonus point: It would be great to include codeception/verify (and other optional add-ons, like domain-assert) in the phar too. Is this possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions