Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpunit throws "Argument #3 (No Value) of PHPUnit_TextUI_ResultPrinter::__construct() must be a value from "never", "auto" or "always""

Tags:

php

phpunit

I'm just test playing with Php unit.

Here is my DependencyFailureTest class:

require_once '../vendor/autoload.php';
use PHPUnit\Framework\TestCase;

class DependencyFailureTest extends \PHPUnit\Framework\TestCase
{
    public function testOne()
    {
        $this->assertTrue(false);
    }

    /**
     * @depends testOne
     */
    public function testTwo()
    {
    }
}

But on running the command phpunit --verbose DependencyFailureTest it throws

Argument #3 (No Value) of PHPUnit_TextUI_ResultPrinter::__construct() must be a value from "never", "auto" or "always".

Can anybody give an explanation for this issue?

like image 228
Ricky Mathew Kuruvilla Avatar asked Oct 30 '22 00:10

Ricky Mathew Kuruvilla


1 Answers

It must be a configuration issue. I copied your code and ran it on the command line with verbose and it worked fine with version 5.4.6.

I would reinstall phpunit and ensure you have the latest version.

Also, their sample test case from their Getting Started page is:

<?php
use PHPUnit\Framework\TestCase;

class MoneyTest extends TestCase
{
    // ...

    public function testCanBeNegated()
    {
        // Arrange
        $a = new Money(1);

        // Act
        $b = $a->negate();

        // Assert
        $this->assertEquals(-1, $b->getAmount());
    }

    // ...
}

https://phpunit.de/getting-started.html

Notice the difference in your extension usage, although I don't think it is an issue, if you use their declaration as stated, it helps to isolate the problem.

like image 163
Katie Avatar answered Nov 15 '22 06:11

Katie