return expect($namedRoute->parameterExists('user'))->toBeTrue(); }); it('should set named parameter to "bruce.wayne"', function () use($routeHandler) { $parameterRoute = new \Cider\Delegation\RoutePath("/users/:user", $routeHandler); $parameterRoute->matches("/users/bruce.wayne"); return expect($parameterRoute->parameterMatches('user', 'bruce.wayne'))->toBeTrue(); }); it('can match route with conditions', function () use($routeHandler) { $conditionRoute = new \Cider\Delegation\RoutePath("/users/:user", $routeHandler); $conditionRoute->condition('user', '([a-z\\.]{1,})'); $hasRouteMatch = $conditionRoute->matches("/users/bruce.wayne"); return expect($hasRouteMatch)->toBeTrue(); }); it('cannot match route to invalid condition', function () use($routeHandler) { $conditionRoute = new \Cider\Delegation\RoutePath("/users/:user", $routeHandler); $conditionRoute->condition('user', '([a-z\\.]{1,})'); $hasRouteMatch = $conditionRoute->matches("/users/brewz-weyn"); return expect($hasRouteMatch)->toBeFalse(); }); it('captures greedy parameters', function () use($routeHandler) { $greedyParameterRoute = new \Cider\Delegation\RoutePath("/users/:usernames+", $routeHandler); $greedyParameterRoute->matches('/users/foo/bar/baz'); return expect($greedyParameterRoute->getParameter('usernames'))->toEqual(['foo', 'bar', 'baz']); }); it('matches optional parameters', function () use($routeHandler) { $optionalParameterRoute = new \Cider\Delegation\RoutePath("/users/:user?", $routeHandler); $matchWithoutOptionalParameter = $optionalParameterRoute->matches('/users/'); $matchWithOptionalParameter = $optionalParameterRoute->matches('/users/harley.quinn'); return expect()->each($matchWithoutOptionalParameter, $matchWithOptionalParameter)->toBeTrue(); }); });
}); it('returns last key from data store with Store::$firstKey getter', function () use($store, $helloWorldDict) { $helloWorldDictKeys = array_keys($helloWorldDict); $firstKeyInHelloWorldDict = $helloWorldDictKeys[0]; return expect($store->firstKey)->toEqual($firstKeyInHelloWorldDict); }); it('returns last key from data store with Store::$lastKey getter', function () use($store, $helloWorldDict) { $helloWorldDictKeys = array_keys($helloWorldDict); $helloWorldDictSize = count($helloWorldDict); $lastKeyInHelloWorldDict = $helloWorldDictKeys[$helloWorldDictSize - 1]; return expect($store->lastKey)->toEqual($lastKeyInHelloWorldDict); }); it('can check if a key exists', function () use($store) { return expect($store->has('en'))->toBeTrue(); }); it('can merge additional stores', function () use($store, $helloWorldDict, $gothamVillainsDict) { $mergedDicts = $helloWorldDict + $gothamVillainsDict; $store->merge($gothamVillainsDict); return expect($store->data)->toEqual($mergedDicts); }); it('can serialize data store', function () use($store, $gothamVillainsDict) { $store->data = $gothamVillainsDict; $jsonString = json_encode($gothamVillainsDict); return expect($store->serialized)->toEqual($jsonString); }); it('can parameterize data store', function () use($store, $gothamVillainsDict) { $store->data = $gothamVillainsDict; $queryString = http_build_query($gothamVillainsDict); return expect($store->parameterized)->toEqual($queryString); }); });
return expect(true)->notToEqual(false); }); it('expects equal any', function () { return expect('foo')->toEqualAny('baz', 'bar', 'foo'); }); it('expects not equal any', function () { return expect('git')->notToEqualAny('php', 'ruby', 'js'); }); it('expects equal all', function () { return expect('nom')->toEqualAll('nom', 'nom', 'nom'); }); it('expects not equal all', function () { return expect('batman')->notToEqualAll('na', 'na', 'na'); }); it('expects truthy', function () { return expect(1)->toBeTruthy(); }); it('expects falsy', function () { return expect(null)->toBeFalsy(); }); it('expects satisfy is_string', function () { return expect('Hello World')->toSatisfy('is_string'); }); it('expects instance of stdClass', function () { $dummyObject = new DummyClassObject(); return expect($dummyObject)->instanceOf('stdClass'); }); it('expects type of string', function () { return expect('Hiya!')->typeOf('string'); }); });