/** * (non-PHPdoc) * @see constraint/LimeConstraintInterface#evaluate($value) */ public function evaluate($value) { try { LimeTester::create($value)->isntSame(LimeTester::create($this->expected)); } catch (LimeAssertionFailedException $e) { throw new LimeConstraintException(sprintf("%s\n must not be identical to\n%s", $e->getActual(), $e->getExpected())); } }
/** * (non-PHPdoc) * @see constraint/LimeConstraintInterface#evaluate($value) */ public function evaluate($value) { try { LimeTester::create($value)->unlike(LimeTester::create($this->expected)); } catch (LimeAssertionFailedException $e) { throw new LimeConstraintException(sprintf(" %s\nmatches %s", $e->getActual(), $e->getExpected())); } }
/** * (non-PHPdoc) * @see constraint/LimeConstraintInterface#evaluate($value) */ public function evaluate($value) { try { LimeTester::create($value)->same(LimeTester::create($this->expected)); } catch (LimeAssertionFailedException $e) { throw new LimeConstraintException(sprintf(" got: %s\nexpected: %s", $e->getActual(10), $e->getExpected(10))); } }
public function offsetGet($key) { return LimeTester::create($this->value[$key]); }
// fixtures $actual = new LimeTesterArray(array('a' => 1, 'b' => 2)); $expected = new LimeTesterArray(array('b' => 2, 'a' => 1)); // test $actual->isntSame($expected); // @Test: contains() throws an exception if a value is not in the array // fixtures $actual = new LimeTesterArray(array(0 => 1)); $expected = LimeTester::create(0); // test $t->expect('LimeAssertionFailedException'); $actual->contains($expected); // @Test: contains() throws no exception if a value is in the array // fixtures $actual = new LimeTesterArray(array(0 => 1)); $expected = LimeTester::create(1); // test $actual->contains($expected); // @Test: containsNot() throws an exception if a value is in the array // fixtures $actual = new LimeTesterArray(array(0 => 1)); $expected = LimeTester::create(1); // test $t->expect('LimeAssertionFailedException'); $actual->containsNot($expected); // @Test: containsNot() throws no exception if a value is not in the array // fixtures $actual = new LimeTesterArray(array(0 => 1)); $expected = LimeTester::create(0); // test $actual->containsNot($expected);
$resource = tmpfile(); $expected = new LimeTesterResource($resource); $t->ok(LimeTester::create($resource) == $expected, 'The correct object was created'); fclose($resource); // @Test: register() registers a new tester for a given class LimeTester::register('TestClass', 'TestClassTester'); $object = new TestClass(); $expected = new TestClassTester($object); $t->ok(LimeTester::create($object) == $expected, 'The correct object was created'); // @Test: register() registers a new tester for a given interface LimeTester::register('TestInterface', 'TestInterfaceTester'); $object = new TestInterfaceClass(); $expected = new TestInterfaceTester($object); $t->ok(LimeTester::create($object) == $expected, 'The correct object was created'); // @Test: unregister() removes any custom testers for a given class LimeTester::register('TestClass', 'TestClassTester'); LimeTester::unregister('TestClass'); $object = new TestClass(); $expected = new LimeTesterObject($object); $t->ok(LimeTester::create($object) == $expected, 'The correct object was created'); // @Test: create() creates a tester also for subclasses of a registered tester LimeTester::register('TestClass', 'TestClassTester'); $object = new TestSubClass(); $expected = new TestClassTester($object); $t->ok(LimeTester::create($object) == $expected, 'The correct object was created'); // @Test: register() throws an exception if the tester class does not exist $t->expect('InvalidArgumentException'); LimeTester::register('TestClass', 'FoobarTester'); // @Test: register() throws an exception if the tester does not implement LimeTesterInterface $t->expect('InvalidArgumentException'); LimeTester::register('TestClass', 'InvalidTester');