11<?php
22
33use Bottledcode \SwytchFramework \Cache \AbstractCache ;
4+ use Bottledcode \SwytchFramework \Cache \CachePublic ;
45use Bottledcode \SwytchFramework \Cache \Control \Tokenizer ;
56use Bottledcode \SwytchFramework \Cache \MaxAge ;
67use Bottledcode \SwytchFramework \Cache \NeverCache ;
78use Bottledcode \SwytchFramework \Cache \NeverChanges ;
89use Bottledcode \SwytchFramework \Cache \Revalidate ;
910use Bottledcode \SwytchFramework \Cache \RevalidationEnum ;
11+ use Bottledcode \SwytchFramework \Cache \UserSpecific ;
1012
1113function render (Tokenizer $ tokenizer , AbstractCache ...$ directives ): string
1214{
@@ -44,7 +46,7 @@ function render(Tokenizer $tokenizer, AbstractCache ...$directives): string
4446 expect (render ($ tokenizer , ...$ directives ))->toBe ("private no-store " );
4547});
4648
47- it ('can handle revalidation rules ' , function () {
49+ it ('can handle revalidation rules ' , function () {
4850 $ tokenizer = new Tokenizer ();
4951
5052 $ directives [] = new NeverChanges ();
@@ -53,7 +55,9 @@ function render(Tokenizer $tokenizer, AbstractCache ...$directives): string
5355 $ directives [] = new Revalidate (RevalidationEnum::AfterStale, 300 );
5456 expect (render ($ tokenizer , ...$ directives ))->toBe ("public stale-while-revalidate=300 stale-if-error=300 " );
5557 $ directives [] = new Revalidate (RevalidationEnum::WhenStaleProxies);
56- expect (render ($ tokenizer , ...$ directives ))->toBe ("public proxy-revalidate stale-while-revalidate=300 stale-if-error=300 " );
58+ expect (render ($ tokenizer , ...$ directives ))->toBe (
59+ "public proxy-revalidate stale-while-revalidate=300 stale-if-error=300 "
60+ );
5761 $ directives [] = new Revalidate (RevalidationEnum::WhenStale);
5862 expect (render ($ tokenizer , ...$ directives ))->toBe ("public must-revalidate proxy-revalidate " );
5963 $ directives [] = new Revalidate (RevalidationEnum::EveryRequest);
@@ -68,3 +72,16 @@ function render(Tokenizer $tokenizer, AbstractCache ...$directives): string
6872 $ directives [] = new MaxAge (300 );
6973 expect (render ($ tokenizer , ...$ directives ))->toBe ("public max-age=300 no-cache " );
7074});
75+
76+ it ('can handle public/private ' , function () {
77+ $ tokenizer = new Tokenizer ();
78+
79+ $ directives [] = new CachePublic ();
80+ expect (render ($ tokenizer , ...$ directives ))->toBe ("public " );
81+
82+ $ directives [] = new UserSpecific ();
83+ expect (render ($ tokenizer , ...$ directives ))->toBe ("private " );
84+
85+ $ directives [] = new CachePublic ();
86+ expect (render ($ tokenizer , ...$ directives ))->toBe ("private " );
87+ });
0 commit comments