elliotchance / concise

✅ Concise is test framework for using plain English and minimal code, built on PHPUnit.
MIT License
45 stars 3 forks source link

Must throw BadMethodCallException on TestCase #317

Closed elliotchance closed 8 years ago

elliotchance commented 8 years ago

Methods that do not exist on TestCase cause bad things to happen, need to throw the appropriate exception like:

    public function __call($name, $args)
    {
        if ($name === '') {
            $name = '_';
        }
        if (substr($name, 0, 6) !== 'assert' &&
            substr($name, 0, 6) !== 'verify') {
            throw new \BadMethodCallException($name);
        }

        $verify = $name[0] === 'v';
        $name = lcfirst(substr($name, 6));

        if (count($args) > 1) {
            $builder = new AssertionBuilder($this, $args[0], $verify);
            /** @noinspection PhpUndefinedMethodInspection */
            return $builder->$name($args[1]);
        }

        $builder = new AssertionBuilder($this, null, $verify);
        /** @noinspection PhpUndefinedMethodInspection */
        return $builder->$name($args[0]);
    }
elliotchance commented 8 years ago

See #318