Git Product home page Git Product logo

phpunit-documentation-english's Introduction

Building the Documentation

Requirements

Building the HTML Documentation

To build the complete documentation run:

make html

phpunit-documentation-english's People

Contributors

astorije avatar baghayi avatar daveh avatar dmalouf avatar edorian avatar elazar avatar gbprod avatar giorgiosironi avatar gleidson2012 avatar henriquemoody avatar jmrieger avatar jon5000 avatar jrfnl avatar keradus avatar lex111 avatar localheinz avatar m-takagi avatar oliverklee avatar plucht avatar poum avatar reinholdfuereder avatar sebastianbergmann avatar sebastianheuer avatar sun avatar suzuki avatar svenrtbg avatar timmartin avatar whatthejeff avatar wynnchen avatar zonuexe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpunit-documentation-english's Issues

Add willReturnOnConsecutiveCalls to documentation

[This duplicates this ticket https://github.com/sebastianbergmann/phpunit-documentation/issues/488 which has been closed since the documentation was moved to separate projects per language]

In phpunit-mock-objects/src/Builder/InvocationMocker.php there's a willReturnOnConsecutiveCalls method, which isn't mentioned in the PHPUnit documentation.
https://github.com/sebastianbergmann/phpunit-mock-objects/blob/master/src/Builder/InvocationMocker.php#L173

Can we get that added please?

Document the development process for the PHPUnit documentation

  • Figure out a strategy (branching and tagging) for maintaining multiple versions of the documentation (ReadTheDocs does not render branches other than master and requires tags for alternative versions)
  • Document how to contribute to an existing language edition of the documentation
  • Document how to build the documentation on a local machine
  • Document how to start a new language edition of the documentation

Document "default-time-limit"

See sebastianbergmann/phpunit#3224 and sebastianbergmann/phpunit#2085

  • "Risky Tests" > "Test Execution Timeout": here is a "Note" panel that should also mention the new option for default timeout
  • "Annotations" > "@Small": here is a "Note" panel that may be removed (because it is also not there for "@Medium" and "@large"), or replaced like above
  • "The XML Configuration File"

Oh and in "The XML Configuration File" the existing option "enforceTimeLimit" is also not documented (this is only mentioned in "Risky Tests"

Russian translation is ready

Hi @sebastianbergmann

I translated this documentation into Russian, the repository is available at this link.

I understand, now I have to transfer you this repository? Do I still have access to it?

And another question that is interesting to me - why not create an organization on GitHub for official repositories that are related to PHPUnit, why this was not done before? For example, here https://github.com/phpspec

failOn* options documentation missing

Hello,

It seems that the attributes failOnRisky and failOnWarning are missing from the XML documentation, I found these on the phpunit.xsd file in the main repository.

Note that --fail-on-risky and --fail-on-warning seems to be missing too in the command line options, even though it's in the --help command

$ phpunit --help
PHPUnit 5.5.4 by Sebastian Bergmann and contributors.

Usage: phpunit [options] UnitTest [UnitTest.php]
       phpunit [options] <directory>

Code Coverage Options:

  --coverage-clover <file>  Generate code coverage report in Clover XML format.
  --coverage-crap4j <file>  Generate code coverage report in Crap4J XML format.
  --coverage-html <dir>     Generate code coverage report in HTML format.
  --coverage-php <file>     Export PHP_CodeCoverage object to file.
  --coverage-text=<file>    Generate code coverage report in text format.
                            Default: Standard output.
  --coverage-xml <dir>      Generate code coverage report in PHPUnit XML format.
  --whitelist <dir>         Whitelist <dir> for code coverage analysis.
  --disable-coverage-ignore Disable annotations for ignoring code coverage.

Logging Options:

  --log-junit <file>        Log test execution in JUnit XML format to file.
  --log-tap <file>          Log test execution in TAP format to file.
  --log-teamcity <file>     Log test execution in TeamCity format to file.
  --log-json <file>         Log test execution in JSON format.
  --testdox-html <file>     Write agile documentation in HTML format to file.
  --testdox-text <file>     Write agile documentation in Text format to file.
  --testdox-xml <file>      Write agile documentation in XML format to file.
  --reverse-list            Print defects in reverse order

Test Selection Options:

  --filter <pattern>        Filter which tests to run.
  --testsuite <pattern>     Filter which testsuite to run.
  --group ...               Only runs tests from the specified group(s).
  --exclude-group ...       Exclude tests from the specified group(s).
  --list-groups             List available test groups.
  --list-suites             List available test suites.
  --test-suffix ...         Only search for test in files with specified
                            suffix(es). Default: Test.php,.phpt

Test Execution Options:

  --report-useless-tests    Be strict about tests that do not test anything.
  --strict-coverage         Be strict about @covers annotation usage.
  --strict-global-state     Be strict about changes to global state
  --disallow-test-output    Be strict about output during tests.
  --disallow-resource-usage Be strict about resource usage during small tests.
  --enforce-time-limit      Enforce time limit based on test size.
  --disallow-todo-tests     Disallow @todo-annotated tests.

  --process-isolation       Run each test in a separate PHP process.
  --no-globals-backup       Do not backup and restore $GLOBALS for each test.
  --static-backup           Backup and restore static attributes for each test.

  --colors=<flag>           Use colors in output ("never", "auto" or "always").
  --columns <n>             Number of columns to use for progress output.
  --columns max             Use maximum number of columns for progress output.
  --stderr                  Write to STDERR instead of STDOUT.
  --stop-on-error           Stop execution upon first error.
  --stop-on-failure         Stop execution upon first error or failure.
  --stop-on-warning         Stop execution upon first warning.
  --stop-on-risky           Stop execution upon first risky test.
  --stop-on-skipped         Stop execution upon first skipped test.
  --stop-on-incomplete      Stop execution upon first incomplete test.
  --fail-on-warning         Treat tests with warnings as failures.
  --fail-on-risky           Treat risky tests as failures.
  -v|--verbose              Output more verbose information.
  --debug                   Display debugging information during test execution.

  --loader <loader>         TestSuiteLoader implementation to use.
  --repeat <times>          Runs the test(s) repeatedly.
  --tap                     Report test execution progress in TAP format.
  --teamcity                Report test execution progress in TeamCity format.
  --testdox                 Report test execution progress in TestDox format.
  --testdox-group           Only include tests from the specified group(s).
  --testdox-exclude-group   Exclude tests from the specified group(s).
  --printer <printer>       TestListener implementation to use.

Configuration Options:

  --bootstrap <file>        A "bootstrap" PHP file that is run before the tests.
  -c|--configuration <file> Read configuration from XML file.
  --no-configuration        Ignore default configuration file (phpunit.xml).
  --no-coverage             Ignore code coverage configuration.
  --include-path <path(s)>  Prepend PHP's include_path with given path(s).
  -d key[=value]            Sets a php.ini value.
  --generate-configuration  Generate configuration file with suggested settings.

Miscellaneous Options:

  -h|--help                 Prints this usage information.
  --version                 Prints the version and exits.
  --atleast-version <min>   Checks that version is greater than min and exits.

Cheers :}

Simplify the contents of the Constraints table

I suggest removing the substring "it is evaluated for" from the following table, because it complicates the general sentence.

Is it not better, compare:

Before After
Constraint that asserts that the value it is evaluated for is greater than a given value. Constraint that asserts that the value is greater than a given value.

Currently some lines of this table do not contain this substring (Constraint that accepts any input value.)

@sebastianbergmann what do you think about this?

documentation for expectException() should say that it will catch multiple exceptions

If a test does this:

    public function testException()
    {
        $this->expectException(\Exception::class);
        
        throw new \Exception;

        throw new \Exception;

    }

then a developer might expect that expectException() will handle the first thrown exception, and fail the second one.

That is not however the case: both exceptions (and presumably an unlimited number) are handled.

The documentation should mention this.

Warnings about bash literal block

rm -rf build/ && make html
…
/Users/klee/src/php/phpunit-documentation-english/src/assertions.rst:1168: WARNING: Could not lex literal_block as "bash". Highlighting skipped.

I'll take care of this.

Removing the closing PHP tags from the examples

How about to slightly simplify the code examples, and remove the closing PHP tags, and maybe even opening PHP tags?

<?php
use PHPUnit\Framework\TestCase;

class ContainsTest extends TestCase
{
    public function testFailure()
    {
        $this->assertContains('baz', 'foobar');
    }
}
?>

The example above will look like this:

use PHPUnit\Framework\TestCase;

class ContainsTest extends TestCase
{
    public function testFailure()
    {
        $this->assertContains('baz', 'foobar');
    }
}

Or even remove the closing tags, because it is customary to omit them. What do you think, @sebastianbergmann?

PHPUnit manual command line options "--report-useless-tests" vs. "--dont-report-useless-tests"

(Re-created for sebastianbergmann/phpunit-documentation#424)

(This is of course just a minor issue...)

See https://phpunit.de/manual/current/en/textui.html#textui.clioptions

At the top it correctly mentions the new option:

Test Execution Options:
--dont-report-useless-tests Do not report tests that do not test anything.

But further down it then explains the old option:

--report-useless-tests
Be strict about tests that do not test anything. See Chapter 6 for details.

Ad comment from @farwish (from 4 April 2017):

The manual may be older, we should see command line.

=> This issue is really only about the minor inconsistency issue in the documentation; the CLI shows:

--dont-report-useless-tests Do not report tests that do not test anything.

How to deal with deprecated features in the documentation

Is there a standard for updating the documentation for dealing with deprecated features?

For example, with the release of PHPUnit 8, annotations for expecting exceptions have been deprecated. Should the documentation about these simply be removed, or marked as deprecated then removed in the documentation for PHPUnit 9 (when they will actually be removed)?

Re-think "Static vs. Non-Static Usage of Assertion Methods" block

Hi, I would like to hear opinions about this block in the documentation.

The PHPUnit documentation is a reference for the PHP community, so, I think that could be worth it to re-think it:

A common question, especially from developers new to PHPUnit, is whether using $this->assertTrue() or self::assertTrue(), for instance, is “the right way” to invoke an assertion. The short answer is: there is no right way. And there is no wrong way, either. It is a matter of personal preference.

If you try to do the same with properties, you will get a PHP Notice like:

Notice: Accessing static property Foo::$bar as non static in /xxx on line N

Proof here: https://3v4l.org/BtqfT

Based on that error, I won't be surprised if PHP also deprecates dynamic access to static methods.

what do you think?

Misleading documentation about doubles

Hello.
In the documentation about test doubles we can read:

Limitation: final, private, and static methods

Please note that final, private, protected, and static methods cannot be stubbed or mocked.

In the body of this limitation block protected method is mentioned though it is not correct because it is possible to create a stub for protected method

Documentation for PHPUnit 8?

Q A
PHPUnit version 8.0.1
PHP version 7.2.10
Installation Method Composer

I just upgraded to PHPUnit 8, but the latest version of documentation on https://phpunit.readthedocs.io/ is for PHPUnit 7.4. Any ideas when this might be updated, or if the documentation for version 8 is available anywhere else?

Document getObjectForTrait()

[This duplicates this ticket https://github.com/sebastianbergmann/phpunit-documentation/issues/345 which has been closed since the documentation was moved to separate projects per language]

There's no mention of the getObjectForTrait method in the documentation.

There was a blog article mentioning this method from 2011 https://sebastian-bergmann.de/archives/906-Testing-Traits.html but that seems to have vanished.

The undocumented code is in phpunit/src/Framework/TestCase.php

Getting started with phpunit: documentation is unclear

I'm following the docs at https://phpunit.readthedocs.io/en/8.0/writing-tests-for-phpunit.html, trying to write my first phpunit tests. I installed phpunit with composer and created a broken test, to validate. However the test won't run. Here's what I did: what am I missing?

$project-dir> composer --dev require phpunit
$project-dir> mkdir tests
$project-dir/tests> // create test file TestTheTest.php

<?php
use PHPUnit\Framework\TestCase;
class TestTheTest extends TestCase
{
    public function testFailure()
    {
        $this->assertEmpty([]);
    }
}
?>

$project-dir/tests>phpunit TestTheTest.php
PHP Fatal error: Class 'PHPUnit\Framework\TestCase' not found in project-dir\tests\TestTheTest.php on line 3
Fatal error: Class 'PHPUnit\Framework\TestCase' not found in project-dir\tests\TestTheTest.php on line 3

"Edit on GitHub" link broken

This issue probably is related to #41 (i.e., it probably blocks it).

Steps to reproduce:

  1. go to https://phpunit.readthedocs.io/en/8.0/ (which is the English version of the docs)
  2. at the bottom of the left sidebar, select any of the following branches: 7.1., 7.2., 7.3., 7.4, 7.5, 8.0
  3. click on the "Edit on GitHub" link at the top of the page

Expected results:
The corresponding file on GitHub, and a URL like this:
https://github.com/sebastianbergmann/phpunit-documentation-english/blob/7.0/src/index.rst

Actual results:
A page that has the text "Not found" on it, and a URL like this:
https://github.com/sebastianbergmann/phpunit-documentation-english//7.1/src/index.rst

Apart from the different version number, the most striking difference seems to be that the broken URLs are missing the "blob" segment. Adding that segment to the broken URL makes it work fine.

With version 7.0, the Edit link is fine. Starting with 7.1, the problem occurs.

Remove annoying words

From https://twitter.com/dbu/status/1056974784251207685:

for the symfony doc, i did a regular expression search with " (simply|simple|just|easy|easily|quick|of course|logically|clearly|obviously|merely|basically|trivial)". "simply" and "of course" are mostly superflous and particularly annoying. the rest is very dependening on context.

Document assertions instroduced in PHPUnit 7.5

The code emits a warning when assertContains is used with strings: Using assertContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringContainsString() or assertStringContainsStringIgnoringCase() instead. but assertStringContainsString() and its siblings are not documented.

Add note about calling parent::setUp()

Note: This is a copy of sebastianbergmann/phpunit-documentation#236

After adding a setUp() method to my database testing class, the database initialization process wasn't happening properly anymore.This seems to be the same problem that was asked and answered here:
http://stackoverflow.com/questions/9490397/dbunit-in-phpunit-is-not-truncating-the-tables

So I added parent::setUp(); as the first line of my setUp() method, and it's working again.
It would be helpful if the phpunit documentation would make it clear that it is important to call parent::setUp() when overriding the setUp() method, in at least some conditions.

It should probably be mentioned in chapter 4 "Fixtures" where it talks about the setUp() method. Perhaps something like: "If you do override setUp(), don't forget to begin with a call to parent::setUp() if this or that condition applies. Otherwise, this or that thing won't happen anymore, with these undesireable results."

And it should probably also be mentioned somewhere in chapter 8 "Database Testing". Perhaps something like: "If you override setUp() as described in chapter 4, be sure to call parent::setUp(), for this and that reason. Otherwise, this or that other thing won't happen, with these undesireable results.

Of course, if one should always start setUp() with a call to parent::setUp(), a short note to that effect in the appropriate place(s) could save those who don't know or remember to do this some time and frustration.

Check occurrences of PHPUnit_

While working on #3 I noticed that in the documentation there are many references to PHPUnit_ classes which were already renamed.

They can be found by searching for PHPUnit_ string in the IDE.

multiple versions support

Hi

Is it planned to have new docs not only for newest version, but also for older ones ?
Like, even when having phpunit 6, there are a lot of ppl still using v4

Test Doubles chapter not quite correct regarding static methods

Ported issue by @llernestal from archived phpunit-documentation repo:
sebastianbergmann/phpunit-documentation#395


The documentation says:

Please note that final, private and static methods cannot be stubbed or mocked. They are ignored by PHPUnit's test double functionality and retain their original behavior.

But static methods DO NOT retain their original behavior. The method body is replaced with:

throw new PHPUnit_Framework_MockObject_BadMethodCallException('Static method "{method_name}" cannot be invoked on mock object');

Maybe the documentation should say something about that?

Code reference

        if ($static) {
            $templateFile = 'mocked_static_method.tpl';
        } else {

https://github.com/sebastianbergmann/phpunit-mock-objects/blob/master/src/Generator.php#L995-L997

    {modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
    {
        throw new \PHPUnit\Framework\MockObject\BadMethodCallException('Static method "{method_name}" cannot be invoked on mock object');
    }

https://github.com/sebastianbergmann/phpunit-mock-objects/blob/master/src/Generator/mocked_static_method.tpl.dist

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.