mardi 21 novembre 2017

PHPUnit test not executing

I am trying to execute some test in PHPUnits but it's not getting executed.

<?php

use \PHPUnit\Framework\TestCase;

class UserControllerTest extends TestCase {

    public function testThatCanGetNumber() {
        $mock = $this->getMockBuilder('UserModel')
            ->setMethods(array('getNumber'))
            ->getMock();

        $mock->expects($this->once())
            ->method('getNumber')
            ->with($this->equalTo(5));
    }
}

However, if I extend the class with \PHPUnit_Framework_TestCase it gets executed. Why is that?

This is my phpunit.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<phpunit bootstrap="vendor/autoload.php"
         colors="true"
         verbose="true"
         stopOnFailure="false">
    <testsuites>
        <testsuite name="Test suite">
            <directory>tests</directory>
        </testsuite>
    </testsuites>
</phpunit>

Aucun commentaire:

Enregistrer un commentaire