mercredi 11 mars 2020

How to unit testing class constructor

I have a class in PHP that I am unit testing, featuring (obviously) a constructor that takes an argument and assigns it to a local, private variable as you would usually assume.

class MyClass
{
    private $_myVar;

    public function _construct(String $someString) {
        $this->_myVar = $someString;
    }
}

I am curious as to how I would unit test this, if at all possible?

I know that $my_var being private will probably obfuscate it from the gaze of any test...

I have seen this article, but it did confuse me a little.

Aucun commentaire:

Enregistrer un commentaire