toBeString() ->and(strlen($hash))->toBe(32) ->and($hash)->toMatch('/^[0-9a-f]{32}$/') ->and($hash)->toBe(sprintf('%016x0000000000000000', spl_object_id($object))); }); test('the same object always hashes to the same value', function () { $object = new stdClass(); expect(cacti_object_hash($object))->toBe(cacti_object_hash($object)); }); test('two distinct live objects hash to different values', function () { $first = new stdClass(); $second = new stdClass(); expect(cacti_object_hash($first))->not->toBe(cacti_object_hash($second)); }); test('non-object arguments return false', function () { expect(cacti_object_hash('a string'))->toBeFalse() ->and(cacti_object_hash(42))->toBeFalse() ->and(cacti_object_hash(3.14))->toBeFalse() ->and(cacti_object_hash(array('an', 'array')))->toBeFalse() ->and(cacti_object_hash(null))->toBeFalse() ->and(cacti_object_hash(true))->toBeFalse(); });