Conjunctions are used tie your subject to your assertions. They control whether the assertion is “positive” (ie, assert that subject is a certain value) or “negative” (subject is not a certain value). There are also “neutral” conjunctions that do not change whether the assertion is positive or negative; they can be used to make your tests more readable. The default set of conjunctions are:

  • is()

  • will()

  • does()

  • has()

  • isNot()

  • willNot()

  • doesNot()

  • and()

  • be()

  • have()


Conjunctions also allow you to pass a description of your assertion to BeBat/Verify. If your assertion fails, PHPUnit will use this description as the failure message. For example:

verify($myObject->isValid())->will('pass validation')->be()->true();

If this assertion fails, you will see Value will pass validation in PHPUnit’s output. BeBat/Verify uses a generic term by default (Value), as well as the conjunction to create the full description. If you would like to use a more descriptive name for your subject you can pass that to verify() as well. For example:

verify($gpa, 'Student GPA')->isNot('failing')->lessThan(2.0);

The description in this case would be Student GPA is not failing.

Custom Conjunctions

Conjunctions are configured through a set of static arrays of strings in BeBat\Verify\API\Base. This allows you to further customize the description messages, as well as tailor the conjunctions to your own writing style. You can manipulate these value like you would any other array. For example:

BeBat\Verify\API\Base::$positiveConjunctions[] = 'to';
BeBat\Verify\API\Base::$positiveConjunctions[] = 'should';

BeBat\Verify\API\Base::$negativeConjunctions[] = 'shouldNot';

BeBat\Verify\API\Base::$neutralConjunctions[] = 'also';
BeBat\Verify\API\Base::$neutralConjunctions[] = 'or';

This should be performed somewhere in your test suite’s bootstrap code so that it is done before any assertions are called and is shared across your tests.