atoum/atoum — pull request #384 by jubianchi (2014-12-09 23:40:52+00:00)
Title: Short syntax for base assertions

Introducing new short syntax for base assertions:

```php
variable('foo')->{'=='}('foo')
->variable('foo')->{'!='}('bar')

->object($this->newInstance)->{'=='}($this->newInstance)
->object($this->newInstance)->{'!='}(new \exception)
->object($this->newTestedInstance)->{'==='}($this->testedInstance)
->object($this->newTestedInstance)->{'!=='}($this->newTestedInstance)

->integer(42)->{42} // isEqualTo
->integer(42)->{'42'} // isEqualTo
->integer(rand(0, 10))->{'<'}(11)
->integer(rand(0, 10))->{'=<'}(10)
->integer(rand(0, 10))->{'>'}(-1)
->integer(rand(0, 10))->{'>='}(0)
;
}
}

```

I was reviewing some code and remembered what we did with @mageekguy on mock call asserter to allow things like `$this->mock($foo)->call('bar')->{3}` to test if the `bar` method was called exactly three times on `$foo`. I asked myself if we can apply similar things to some other asserters, basically `variable` and `integer` to cover assertion that have an native operator counterpart (i.e `isEqualTo`, `isIdenticalTo`, ...).

As you have seen in the previous example, this is doable and works fine (I tested it from PHP 5.4 to 5.6). Let me know if you think this is useful ;)