[{"data":1,"prerenderedAt":1724},["ShallowReactive",2],{"navigation":3,"\u002Ftesting-and-tooling\u002Ftesting":173,"\u002Ftesting-and-tooling\u002Ftesting-surround":1719},[4,27,69,103,113,135],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":26},"Getting Started","i-heroicons-star","\u002Fgetting-started","1.getting-started",[10,14,18,22],{"title":11,"path":12,"stem":13},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F1.introduction",{"title":15,"path":16,"stem":17},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F2.installation",{"title":19,"path":20,"stem":21},"Quick start","\u002Fgetting-started\u002Fquick-start","1.getting-started\u002F3.quick-start",{"title":23,"path":24,"stem":25},"Upgrade guide","\u002Fgetting-started\u002Fupgrade-guide","1.getting-started\u002F5.upgrade-guide",false,{"title":28,"icon":29,"path":30,"stem":31,"children":32,"page":26},"Essentials","i-heroicons-shield-check","\u002Fessentials","2.essentials",[33,37,41,45,49,53,57,61,65],{"title":34,"path":35,"stem":36},"Controls","\u002Fessentials\u002Fcontrols","2.essentials\u002F1.controls",{"title":38,"path":39,"stem":40},"Perimeters","\u002Fessentials\u002Fperimeters","2.essentials\u002F2.perimeters",{"title":42,"path":43,"stem":44},"Perimeter classes","\u002Fessentials\u002Fperimeter-classes","2.essentials\u002F3.perimeter-classes",{"title":46,"path":47,"stem":48},"Levels","\u002Fessentials\u002Flevels","2.essentials\u002F4.levels",{"title":50,"path":51,"stem":52},"Boundaries","\u002Fessentials\u002Fboundaries","2.essentials\u002F5.boundaries",{"title":54,"path":55,"stem":56},"Parents","\u002Fessentials\u002Fparents","2.essentials\u002F6.parents",{"title":58,"path":59,"stem":60},"Policies","\u002Fessentials\u002Fpolicies","2.essentials\u002F7.policies",{"title":62,"path":63,"stem":64},"Queries","\u002Fessentials\u002Fqueries","2.essentials\u002F8.queries",{"title":66,"path":67,"stem":68},"Readers","\u002Fessentials\u002Freaders","2.essentials\u002F9.readers",{"title":70,"icon":71,"path":72,"stem":73,"children":74,"page":26},"Search","i-heroicons-magnifying-glass","\u002Fsearch","3.search",[75,79,83,87,91,95,99],{"title":76,"path":77,"stem":78},"Search overview","\u002Fsearch\u002Foverview","3.search\u002F1.overview",{"title":80,"path":81,"stem":82},"Engines","\u002Fsearch\u002Fengines","3.search\u002F2.engines",{"title":84,"path":85,"stem":86},"Keeping the keys fresh","\u002Fsearch\u002Fkeeping-the-keys-fresh","3.search\u002F3.keeping-the-keys-fresh",{"title":88,"path":89,"stem":90},"Exceptions and dates","\u002Fsearch\u002Fexceptions-and-dates","3.search\u002F4.exceptions-and-dates",{"title":92,"path":93,"stem":94},"Searching through a parent","\u002Fsearch\u002Fthrough-a-parent","3.search\u002F5.through-a-parent",{"title":96,"path":97,"stem":98},"Search from the browser","\u002Fsearch\u002Ffrom-the-browser","3.search\u002F6.from-the-browser",{"title":100,"path":101,"stem":102},"Your own search client","\u002Fsearch\u002Fyour-own-client","3.search\u002F7.your-own-client",{"title":104,"icon":105,"path":106,"stem":107,"children":108,"page":26},"Integrations","i-heroicons-puzzle-piece","\u002Fintegrations","4.integrations",[109],{"title":110,"path":111,"stem":112},"laravel-rest-api","\u002Fintegrations\u002Flaravel-rest-api","4.integrations\u002F1.laravel-rest-api",{"title":114,"icon":115,"path":116,"stem":117,"children":118,"page":26},"Testing and Tooling","i-heroicons-wrench-screwdriver","\u002Ftesting-and-tooling","5.testing-and-tooling",[119,123,127,131],{"title":120,"path":121,"stem":122},"Testing","\u002Ftesting-and-tooling\u002Ftesting","5.testing-and-tooling\u002F1.testing",{"title":124,"path":125,"stem":126},"access:check","\u002Ftesting-and-tooling\u002Faccess-check","5.testing-and-tooling\u002F2.access-check",{"title":128,"path":129,"stem":130},"Cache and about","\u002Ftesting-and-tooling\u002Fcache-and-about","5.testing-and-tooling\u002F3.cache-and-about",{"title":132,"path":133,"stem":134},"Generators","\u002Ftesting-and-tooling\u002Fgenerators","5.testing-and-tooling\u002F4.generators",{"title":136,"icon":137,"path":138,"stem":139,"children":140,"page":26},"Digging Deeper","i-heroicons-list-bullet","\u002Fdigging-deeper","6.digging-deeper",[141,145,149,153,157,161,165,169],{"title":142,"path":143,"stem":144},"Abilities","\u002Fdigging-deeper\u002Fabilities","6.digging-deeper\u002F1.abilities",{"title":146,"path":147,"stem":148},"Kept decisions","\u002Fdigging-deeper\u002Fdecisions","6.digging-deeper\u002F2.decisions",{"title":150,"path":151,"stem":152},"Batched decisions","\u002Fdigging-deeper\u002Fbatched-decisions","6.digging-deeper\u002F3.batched-decisions",{"title":154,"path":155,"stem":156},"Row checks","\u002Fdigging-deeper\u002Frow-checks","6.digging-deeper\u002F4.row-checks",{"title":158,"path":159,"stem":160},"Several brands","\u002Fdigging-deeper\u002Fseveral-brands","6.digging-deeper\u002F5.several-brands",{"title":162,"path":163,"stem":164},"Row context","\u002Fdigging-deeper\u002Frow-context","6.digging-deeper\u002F6.row-context",{"title":166,"path":167,"stem":168},"What is public in 1.x","\u002Fdigging-deeper\u002Fpublic-api","6.digging-deeper\u002F7.public-api",{"title":170,"path":171,"stem":172},"Use with AI","\u002Fdigging-deeper\u002Fuse-with-ai","6.digging-deeper\u002F8.use-with-ai",{"id":174,"title":120,"body":175,"description":1711,"extension":1712,"links":1713,"meta":1714,"navigation":217,"path":121,"seo":1715,"sitemap":1716,"stem":122,"updatedAt":1717,"__hash__":1718},"docs\u002F5.testing-and-tooling\u002F1.testing.md",{"type":176,"value":177,"toc":1700},"minimark",[178,940,948,958,963,969,1068,1071,1097,1117,1128,1160,1164,1174,1217,1241,1245,1251,1294,1305,1310,1313,1373,1384,1428,1432,1462,1509,1514,1517,1530,1534,1553,1564,1661,1665,1675,1696],[179,180,186],"pre",{"className":181,"code":182,"filename":183,"language":184,"meta":185,"style":185},"language-php shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","namespace Tests\\Feature;\n\nuse App\\Access\\Controls\\PostControl;\nuse App\\Models\\Post;\nuse App\\Models\\User;\nuse Illuminate\\Foundation\\Testing\\RefreshDatabase;\nuse Lomkit\\Access\\Testing\\InteractsWithAccess;\nuse Tests\\TestCase;\n\nclass PostControlTest extends TestCase\n{\n    use InteractsWithAccess, RefreshDatabase;\n\n    public function test_its_rules_agree(): void\n    {\n        \u002F\u002F Give each reader the permissions your application gives it.\n        $admin = User::factory()->create(['client_id' => 1]);   \u002F\u002F \"... all posts\"\n        $manager = User::factory()->create(['client_id' => 1]); \u002F\u002F \"... client posts\"\n        $author = User::factory()->create(['client_id' => 1]);  \u002F\u002F \"... own posts\"\n        $other = User::factory()->create(['client_id' => 2]);   \u002F\u002F \"... own posts\"\n\n        Post::factory()->create(['client_id' => 1, 'author_id' => $author->id]);\n        Post::factory()->create(['client_id' => 1, 'author_id' => $manager->id]);\n        Post::factory()->create(['client_id' => 2, 'author_id' => $other->id]);\n\n        $readers = [$admin, $manager, $author, $other];\n\n        foreach ($readers as $reader) {\n            $this->assertControlAgrees(PostControl::class, $reader, Post::uncontrolled()->get());\n        }\n\n        $this->assertLevelsNest(PostControl::class, readers: $readers);\n        $this->assertSearchAgrees(PostControl::class, readers: $readers); \u002F\u002F with Laravel Scout\n    }\n}\n","tests\u002FFeature\u002FPostControlTest.php","php","",[187,188,189,212,219,245,264,282,306,329,343,348,364,370,387,392,411,417,424,475,512,549,587,592,645,691,737,742,779,784,810,852,858,863,896,928,934],"code",{"__ignoreMap":185},[190,191,194,198,202,206,209],"span",{"class":192,"line":193},"line",1,[190,195,197],{"class":196},"sbssI","namespace",[190,199,201],{"class":200},"sBMFI"," Tests",[190,203,205],{"class":204},"sMK4o","\\",[190,207,208],{"class":200},"Feature",[190,210,211],{"class":204},";\n",[190,213,215],{"class":192,"line":214},2,[190,216,218],{"emptyLinePlaceholder":217},true,"\n",[190,220,222,225,229,231,234,236,238,240,243],{"class":192,"line":221},3,[190,223,224],{"class":196},"use",[190,226,228],{"class":227},"sTEyZ"," App",[190,230,205],{"class":204},[190,232,233],{"class":227},"Access",[190,235,205],{"class":204},[190,237,34],{"class":227},[190,239,205],{"class":204},[190,241,242],{"class":227},"PostControl",[190,244,211],{"class":204},[190,246,248,250,252,254,257,259,262],{"class":192,"line":247},4,[190,249,224],{"class":196},[190,251,228],{"class":227},[190,253,205],{"class":204},[190,255,256],{"class":227},"Models",[190,258,205],{"class":204},[190,260,261],{"class":227},"Post",[190,263,211],{"class":204},[190,265,267,269,271,273,275,277,280],{"class":192,"line":266},5,[190,268,224],{"class":196},[190,270,228],{"class":227},[190,272,205],{"class":204},[190,274,256],{"class":227},[190,276,205],{"class":204},[190,278,279],{"class":227},"User",[190,281,211],{"class":204},[190,283,285,287,290,292,295,297,299,301,304],{"class":192,"line":284},6,[190,286,224],{"class":196},[190,288,289],{"class":227}," Illuminate",[190,291,205],{"class":204},[190,293,294],{"class":227},"Foundation",[190,296,205],{"class":204},[190,298,120],{"class":227},[190,300,205],{"class":204},[190,302,303],{"class":227},"RefreshDatabase",[190,305,211],{"class":204},[190,307,309,311,314,316,318,320,322,324,327],{"class":192,"line":308},7,[190,310,224],{"class":196},[190,312,313],{"class":227}," Lomkit",[190,315,205],{"class":204},[190,317,233],{"class":227},[190,319,205],{"class":204},[190,321,120],{"class":227},[190,323,205],{"class":204},[190,325,326],{"class":227},"InteractsWithAccess",[190,328,211],{"class":204},[190,330,332,334,336,338,341],{"class":192,"line":331},8,[190,333,224],{"class":196},[190,335,201],{"class":227},[190,337,205],{"class":204},[190,339,340],{"class":227},"TestCase",[190,342,211],{"class":204},[190,344,346],{"class":192,"line":345},9,[190,347,218],{"emptyLinePlaceholder":217},[190,349,351,355,358,361],{"class":192,"line":350},10,[190,352,354],{"class":353},"spNyl","class",[190,356,357],{"class":200}," PostControlTest",[190,359,360],{"class":353}," extends",[190,362,363],{"class":200}," TestCase\n",[190,365,367],{"class":192,"line":366},11,[190,368,369],{"class":204},"{\n",[190,371,373,376,379,382,385],{"class":192,"line":372},12,[190,374,375],{"class":196},"    use",[190,377,378],{"class":227}," InteractsWithAccess",[190,380,381],{"class":204},",",[190,383,384],{"class":227}," RefreshDatabase",[190,386,211],{"class":204},[190,388,390],{"class":192,"line":389},13,[190,391,218],{"emptyLinePlaceholder":217},[190,393,395,398,401,405,408],{"class":192,"line":394},14,[190,396,397],{"class":353},"    public",[190,399,400],{"class":353}," function",[190,402,404],{"class":403},"s2Zo4"," test_its_rules_agree",[190,406,407],{"class":204},"():",[190,409,410],{"class":196}," void\n",[190,412,414],{"class":192,"line":413},15,[190,415,416],{"class":204},"    {\n",[190,418,420],{"class":192,"line":419},16,[190,421,423],{"class":422},"sHwdD","        \u002F\u002F Give each reader the permissions your application gives it.\n",[190,425,427,430,433,436,439,442,445,448,451,454,457,461,463,466,469,472],{"class":192,"line":426},17,[190,428,429],{"class":204},"        $",[190,431,432],{"class":227},"admin ",[190,434,435],{"class":204},"=",[190,437,438],{"class":200}," User",[190,440,441],{"class":204},"::",[190,443,444],{"class":403},"factory",[190,446,447],{"class":204},"()->",[190,449,450],{"class":403},"create",[190,452,453],{"class":204},"([",[190,455,456],{"class":204},"'",[190,458,460],{"class":459},"sfazB","client_id",[190,462,456],{"class":204},[190,464,465],{"class":204}," =>",[190,467,468],{"class":196}," 1",[190,470,471],{"class":204},"]);",[190,473,474],{"class":422},"   \u002F\u002F \"... all posts\"\n",[190,476,478,480,483,485,487,489,491,493,495,497,499,501,503,505,507,509],{"class":192,"line":477},18,[190,479,429],{"class":204},[190,481,482],{"class":227},"manager ",[190,484,435],{"class":204},[190,486,438],{"class":200},[190,488,441],{"class":204},[190,490,444],{"class":403},[190,492,447],{"class":204},[190,494,450],{"class":403},[190,496,453],{"class":204},[190,498,456],{"class":204},[190,500,460],{"class":459},[190,502,456],{"class":204},[190,504,465],{"class":204},[190,506,468],{"class":196},[190,508,471],{"class":204},[190,510,511],{"class":422}," \u002F\u002F \"... client posts\"\n",[190,513,515,517,520,522,524,526,528,530,532,534,536,538,540,542,544,546],{"class":192,"line":514},19,[190,516,429],{"class":204},[190,518,519],{"class":227},"author ",[190,521,435],{"class":204},[190,523,438],{"class":200},[190,525,441],{"class":204},[190,527,444],{"class":403},[190,529,447],{"class":204},[190,531,450],{"class":403},[190,533,453],{"class":204},[190,535,456],{"class":204},[190,537,460],{"class":459},[190,539,456],{"class":204},[190,541,465],{"class":204},[190,543,468],{"class":196},[190,545,471],{"class":204},[190,547,548],{"class":422},"  \u002F\u002F \"... own posts\"\n",[190,550,552,554,557,559,561,563,565,567,569,571,573,575,577,579,582,584],{"class":192,"line":551},20,[190,553,429],{"class":204},[190,555,556],{"class":227},"other ",[190,558,435],{"class":204},[190,560,438],{"class":200},[190,562,441],{"class":204},[190,564,444],{"class":403},[190,566,447],{"class":204},[190,568,450],{"class":403},[190,570,453],{"class":204},[190,572,456],{"class":204},[190,574,460],{"class":459},[190,576,456],{"class":204},[190,578,465],{"class":204},[190,580,581],{"class":196}," 2",[190,583,471],{"class":204},[190,585,586],{"class":422},"   \u002F\u002F \"... own posts\"\n",[190,588,590],{"class":192,"line":589},21,[190,591,218],{"emptyLinePlaceholder":217},[190,593,595,598,600,602,604,606,608,610,612,614,616,618,620,623,626,628,630,633,636,639,642],{"class":192,"line":594},22,[190,596,597],{"class":200},"        Post",[190,599,441],{"class":204},[190,601,444],{"class":403},[190,603,447],{"class":204},[190,605,450],{"class":403},[190,607,453],{"class":204},[190,609,456],{"class":204},[190,611,460],{"class":459},[190,613,456],{"class":204},[190,615,465],{"class":204},[190,617,468],{"class":196},[190,619,381],{"class":204},[190,621,622],{"class":204}," '",[190,624,625],{"class":459},"author_id",[190,627,456],{"class":204},[190,629,465],{"class":204},[190,631,632],{"class":204}," $",[190,634,635],{"class":227},"author",[190,637,638],{"class":204},"->",[190,640,641],{"class":227},"id",[190,643,644],{"class":204},"]);\n",[190,646,648,650,652,654,656,658,660,662,664,666,668,670,672,674,676,678,680,682,685,687,689],{"class":192,"line":647},23,[190,649,597],{"class":200},[190,651,441],{"class":204},[190,653,444],{"class":403},[190,655,447],{"class":204},[190,657,450],{"class":403},[190,659,453],{"class":204},[190,661,456],{"class":204},[190,663,460],{"class":459},[190,665,456],{"class":204},[190,667,465],{"class":204},[190,669,468],{"class":196},[190,671,381],{"class":204},[190,673,622],{"class":204},[190,675,625],{"class":459},[190,677,456],{"class":204},[190,679,465],{"class":204},[190,681,632],{"class":204},[190,683,684],{"class":227},"manager",[190,686,638],{"class":204},[190,688,641],{"class":227},[190,690,644],{"class":204},[190,692,694,696,698,700,702,704,706,708,710,712,714,716,718,720,722,724,726,728,731,733,735],{"class":192,"line":693},24,[190,695,597],{"class":200},[190,697,441],{"class":204},[190,699,444],{"class":403},[190,701,447],{"class":204},[190,703,450],{"class":403},[190,705,453],{"class":204},[190,707,456],{"class":204},[190,709,460],{"class":459},[190,711,456],{"class":204},[190,713,465],{"class":204},[190,715,581],{"class":196},[190,717,381],{"class":204},[190,719,622],{"class":204},[190,721,625],{"class":459},[190,723,456],{"class":204},[190,725,465],{"class":204},[190,727,632],{"class":204},[190,729,730],{"class":227},"other",[190,732,638],{"class":204},[190,734,641],{"class":227},[190,736,644],{"class":204},[190,738,740],{"class":192,"line":739},25,[190,741,218],{"emptyLinePlaceholder":217},[190,743,745,747,750,752,755,758,760,762,764,766,768,770,772,774,776],{"class":192,"line":744},26,[190,746,429],{"class":204},[190,748,749],{"class":227},"readers ",[190,751,435],{"class":204},[190,753,754],{"class":204}," [$",[190,756,757],{"class":227},"admin",[190,759,381],{"class":204},[190,761,632],{"class":204},[190,763,684],{"class":227},[190,765,381],{"class":204},[190,767,632],{"class":204},[190,769,635],{"class":227},[190,771,381],{"class":204},[190,773,632],{"class":204},[190,775,730],{"class":227},[190,777,778],{"class":204},"];\n",[190,780,782],{"class":192,"line":781},27,[190,783,218],{"emptyLinePlaceholder":217},[190,785,787,791,794,796,799,801,804,807],{"class":192,"line":786},28,[190,788,790],{"class":789},"s7zQu","        foreach",[190,792,793],{"class":204}," ($",[190,795,749],{"class":227},[190,797,798],{"class":204},"as",[190,800,632],{"class":204},[190,802,803],{"class":227},"reader",[190,805,806],{"class":204},")",[190,808,809],{"class":204}," {\n",[190,811,813,816,819,822,824,826,828,830,832,834,836,839,841,844,846,849],{"class":192,"line":812},29,[190,814,815],{"class":204},"            $this->",[190,817,818],{"class":403},"assertControlAgrees",[190,820,821],{"class":204},"(",[190,823,242],{"class":200},[190,825,441],{"class":204},[190,827,354],{"class":196},[190,829,381],{"class":204},[190,831,632],{"class":204},[190,833,803],{"class":227},[190,835,381],{"class":204},[190,837,838],{"class":200}," Post",[190,840,441],{"class":204},[190,842,843],{"class":403},"uncontrolled",[190,845,447],{"class":204},[190,847,848],{"class":403},"get",[190,850,851],{"class":204},"());\n",[190,853,855],{"class":192,"line":854},30,[190,856,857],{"class":204},"        }\n",[190,859,861],{"class":192,"line":860},31,[190,862,218],{"emptyLinePlaceholder":217},[190,864,866,869,872,874,876,878,880,882,885,888,890,893],{"class":192,"line":865},32,[190,867,868],{"class":204},"        $this->",[190,870,871],{"class":403},"assertLevelsNest",[190,873,821],{"class":204},[190,875,242],{"class":200},[190,877,441],{"class":204},[190,879,354],{"class":196},[190,881,381],{"class":204},[190,883,884],{"class":200}," readers",[190,886,887],{"class":204},":",[190,889,632],{"class":204},[190,891,892],{"class":227},"readers",[190,894,895],{"class":204},");\n",[190,897,899,901,904,906,908,910,912,914,916,918,920,922,925],{"class":192,"line":898},33,[190,900,868],{"class":204},[190,902,903],{"class":403},"assertSearchAgrees",[190,905,821],{"class":204},[190,907,242],{"class":200},[190,909,441],{"class":204},[190,911,354],{"class":196},[190,913,381],{"class":204},[190,915,884],{"class":200},[190,917,887],{"class":204},[190,919,632],{"class":204},[190,921,892],{"class":227},[190,923,924],{"class":204},");",[190,926,927],{"class":422}," \u002F\u002F with Laravel Scout\n",[190,929,931],{"class":192,"line":930},34,[190,932,933],{"class":204},"    }\n",[190,935,937],{"class":192,"line":936},35,[190,938,939],{"class":204},"}\n",[941,942,943,944,947],"p",{},"The ",[187,945,946],{},"Lomkit\\Access\\Testing\\InteractsWithAccess"," trait adds assertions that compare the ways of deciding with each other, for the readers and the rows of your test.",[949,950,951],"warning",{},[941,952,953,957],{},[954,955,956],"strong",{},"A reader without permissions proves nothing."," A reader that no perimeter allows sees no row on every path, so every assertion passes. Give each reader the permissions your application gives it, and seed the rows that each perimeter reaches: the assertions prove the agreement on the rows of the test only.",[959,960,962],"h2",{"id":961},"the-decisions","The decisions",[941,964,965,968],{},[187,966,967],{},"assertControlAgrees()"," checks that every way of deciding gives the same answer, for each ability and each row:",[179,970,972],{"className":181,"code":971,"language":184,"meta":185,"style":185},"$this->assertControlAgrees(PostControl::class, $reader, Post::uncontrolled()->get());\n$this->assertControlAgrees(PostControl::class, $reader, $posts, ['view', 'update', 'approve']);\n",[187,973,974,1009],{"__ignoreMap":185},[190,975,976,979,981,983,985,987,989,991,993,995,997,999,1001,1003,1005,1007],{"class":192,"line":193},[190,977,978],{"class":204},"$this->",[190,980,818],{"class":403},[190,982,821],{"class":204},[190,984,242],{"class":200},[190,986,441],{"class":204},[190,988,354],{"class":196},[190,990,381],{"class":204},[190,992,632],{"class":204},[190,994,803],{"class":227},[190,996,381],{"class":204},[190,998,838],{"class":200},[190,1000,441],{"class":204},[190,1002,843],{"class":403},[190,1004,447],{"class":204},[190,1006,848],{"class":403},[190,1008,851],{"class":204},[190,1010,1011,1013,1015,1017,1019,1021,1023,1025,1027,1029,1031,1033,1036,1038,1041,1043,1046,1048,1050,1052,1055,1057,1059,1061,1064,1066],{"class":192,"line":214},[190,1012,978],{"class":204},[190,1014,818],{"class":403},[190,1016,821],{"class":204},[190,1018,242],{"class":200},[190,1020,441],{"class":204},[190,1022,354],{"class":196},[190,1024,381],{"class":204},[190,1026,632],{"class":204},[190,1028,803],{"class":227},[190,1030,381],{"class":204},[190,1032,632],{"class":204},[190,1034,1035],{"class":227},"posts",[190,1037,381],{"class":204},[190,1039,1040],{"class":204}," [",[190,1042,456],{"class":204},[190,1044,1045],{"class":459},"view",[190,1047,456],{"class":204},[190,1049,381],{"class":204},[190,1051,622],{"class":204},[190,1053,1054],{"class":459},"update",[190,1056,456],{"class":204},[190,1058,381],{"class":204},[190,1060,622],{"class":204},[190,1062,1063],{"class":459},"approve",[190,1065,456],{"class":204},[190,1067,644],{"class":204},[941,1069,1070],{},"It compares four paths:",[1072,1073,1074,1078,1085,1090],"ul",{},[1075,1076,1077],"li",{},"the Gate, row by row, with no decision kept;",[1075,1079,1080,1081,1084],{},"the Gate after ",[187,1082,1083],{},"Access::preload()",";",[1075,1086,1080,1087,1084],{},[187,1088,1089],{},"withAbilities()",[1075,1091,1092,1093,1096],{},"whether ",[187,1094,1095],{},"controlledFor($reader, $ability)"," lists the row.",[941,1098,1099,1100,1102,1103,1105,1106,1109,1110,1112,1113,1116],{},"The abilities default to ",[187,1101,1045],{},", ",[187,1104,1054],{}," and ",[187,1107,1108],{},"delete","; pass others as the fourth argument. ",[187,1111,450],{}," is compared through the Gate only, since it is judged on drafts, and ",[187,1114,1115],{},"viewAny"," too, since it decides without a row. The rows must be saved rows of the control's model.",[941,1118,1119,1120,1123,1124,1127],{},"A failure names the reader, then each row key and ability that disagree, with the answer of each path: ",[187,1121,1122],{},"granted",", a refusal code, or ",[187,1125,1126],{},"denied without a code"," when no policy decided. The usual causes:",[1072,1129,1130,1144],{},[1075,1131,1132,1133,1136,1137,1140,1141,1084],{},"a ",[187,1134,1135],{},"should()"," callback or an ",[187,1138,1139],{},"includes()"," hook that describes other rows than its ",[187,1142,1143],{},"query()",[1075,1145,1146,1147,1150,1151,1154,1155,1159],{},"a policy method that adds its own rule, such as an ",[187,1148,1149],{},"update()"," override that refuses some rows: the Gate then grants fewer rows than ",[187,1152,1153],{},"controlled('update')"," lists. Move the rule into the control, see ",[1156,1157,58],"a",{"href":1158},"\u002Fessentials\u002Fpolicies#keep-the-rules-in-the-control",".",[959,1161,1163],{"id":1162},"the-levels","The levels",[941,1165,1166,1169,1170,1173],{},[187,1167,1168],{},"assertLevelsNest()"," checks, for each reader and each pair of adjacent levels of every ",[187,1171,1172],{},"Levels::of()"," group, that no row of the lower level, inside the boundary, is missing from the upper level:",[179,1175,1177],{"className":181,"code":1176,"language":184,"meta":185,"style":185},"$this->assertLevelsNest(PostControl::class, readers: [$author, $manager, $admin]);\n",[187,1178,1179],{"__ignoreMap":185},[190,1180,1181,1183,1185,1187,1189,1191,1193,1195,1197,1199,1201,1203,1205,1207,1209,1211,1213,1215],{"class":192,"line":193},[190,1182,978],{"class":204},[190,1184,871],{"class":403},[190,1186,821],{"class":204},[190,1188,242],{"class":200},[190,1190,441],{"class":204},[190,1192,354],{"class":196},[190,1194,381],{"class":204},[190,1196,884],{"class":200},[190,1198,887],{"class":204},[190,1200,754],{"class":204},[190,1202,635],{"class":227},[190,1204,381],{"class":204},[190,1206,632],{"class":204},[190,1208,684],{"class":227},[190,1210,381],{"class":204},[190,1212,632],{"class":204},[190,1214,757],{"class":227},[190,1216,644],{"class":204},[941,1218,1219,1220,1222,1223,1225,1226,1229,1230,1233,1234,1237,1238,1159],{},"It reads the rows of the ",[187,1221,1143],{}," callbacks for ",[187,1224,1045],{},", not the ",[187,1227,1228],{},"allowed()"," callbacks, and compares them with ",[187,1231,1232],{},"not exists"," on the key, so a ",[187,1235,1236],{},"NULL"," in a column cannot hide a missing row. Seed the rows that each level reaches. See ",[1156,1239,46],{"href":1240},"\u002Fessentials\u002Flevels#levels-nest",[959,1242,1244],{"id":1243},"the-search","The search",[941,1246,1247,1250],{},[187,1248,1249],{},"assertSearchAgrees()"," checks, for each reader, that the rows the search keys find are the rows of the controlled query:",[179,1252,1254],{"className":181,"code":1253,"language":184,"meta":185,"style":185},"$this->assertSearchAgrees(PostControl::class, readers: [$admin, $manager, $author]);\n",[187,1255,1256],{"__ignoreMap":185},[190,1257,1258,1260,1262,1264,1266,1268,1270,1272,1274,1276,1278,1280,1282,1284,1286,1288,1290,1292],{"class":192,"line":193},[190,1259,978],{"class":204},[190,1261,903],{"class":403},[190,1263,821],{"class":204},[190,1265,242],{"class":200},[190,1267,441],{"class":204},[190,1269,354],{"class":196},[190,1271,381],{"class":204},[190,1273,884],{"class":200},[190,1275,887],{"class":204},[190,1277,754],{"class":204},[190,1279,757],{"class":227},[190,1281,381],{"class":204},[190,1283,632],{"class":204},[190,1285,684],{"class":227},[190,1287,381],{"class":204},[190,1289,632],{"class":204},[190,1291,635],{"class":227},[190,1293,644],{"class":204},[1072,1295,1296,1299,1302],{},[1075,1297,1298],{},"It computes the keys of the rows and of the readers from the same declarations as the indexing, without any engine, and compares their digests, as the engine receives them. It proves the logic of your keys, not the behaviour of the engine.",[1075,1300,1301],{},"A failure lists the readable keys of the reader and of each row in disagreement, the first ten of each list.",[1075,1303,1304],{},"A perimeter that applies to the reader without search keys makes it fail: the search would be narrower than the SQL.",[1306,1307,1309],"h3",{"id":1308},"the-clock-check","The clock check",[941,1311,1312],{},"Before comparing, the assertion checks that each row gets the same keys at any instant, since an index keeps the keys of the instant the row was written. It computes the keys of the rows of the test at the current instant, and again with the clock frozen 400 days earlier and 400 days later, and fails when the keys of a row differ.",[1072,1314,1315,1330,1363,1366],{},[1075,1316,1317,1318,1321,1322,1325,1326,1159],{},"The failure names the row, the field and the key rules: a ",[187,1319,1320],{},"row"," callback that reads the clock, or one that gives other keys each time, such as ",[187,1323,1324],{},"first()"," on a relation without an order. See ",[1156,1327,1329],{"href":1328},"\u002Fsearch\u002Fexceptions-and-dates#rights-that-depend-on-the-date","Rights that depend on the date",[1075,1331,1332,1333,1102,1336,1102,1339,1102,1342,1105,1345,1348,1349,1102,1352,1355,1356,1359,1360,1159],{},"It sees what reads Laravel's clock: ",[187,1334,1335],{},"now()",[187,1337,1338],{},"Date::now()",[187,1340,1341],{},"Illuminate\\Support\\Carbon::now()",[187,1343,1344],{},"Carbon\\Carbon::now()",[187,1346,1347],{},"Carbon\\CarbonImmutable::now()",". It does not see PHP's ",[187,1350,1351],{},"time()",[187,1353,1354],{},"date()"," or ",[187,1357,1358],{},"new DateTimeImmutable()",", nor a database ",[187,1361,1362],{},"NOW()",[1075,1364,1365],{},"It catches a clock read only when the keys of a test row change between these instants: give the rows of the test a period that starts or ends within 400 days of the instant of the test.",[1075,1367,1368,1369,1372],{},"The clock is set back afterwards, also after a failure: a test that froze it with ",[187,1370,1371],{},"travelTo()"," keeps its instant.",[941,1374,1375,1376,1379,1380,1383],{},"A test that runs controlled searches uses the ",[187,1377,1378],{},"database"," engine, not ",[187,1381,1382],{},"collection",", which refuses them:",[179,1385,1390],{"className":1386,"code":1387,"filename":1388,"language":1389,"meta":185,"style":185},"language-xml shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u003Cenv name=\"SCOUT_DRIVER\" value=\"database\"\u002F>\n","phpunit.xml","xml",[187,1391,1392],{"__ignoreMap":185},[190,1393,1394,1397,1401,1404,1406,1409,1412,1414,1417,1419,1421,1423,1425],{"class":192,"line":193},[190,1395,1396],{"class":204},"\u003C",[190,1398,1400],{"class":1399},"swJcz","env",[190,1402,1403],{"class":353}," name",[190,1405,435],{"class":204},[190,1407,1408],{"class":204},"\"",[190,1410,1411],{"class":459},"SCOUT_DRIVER",[190,1413,1408],{"class":204},[190,1415,1416],{"class":353}," value",[190,1418,435],{"class":204},[190,1420,1408],{"class":204},[190,1422,1378],{"class":459},[190,1424,1408],{"class":204},[190,1426,1427],{"class":204},"\u002F>\n",[959,1429,1431],{"id":1430},"an-index-of-your-own","An index of your own",[941,1433,1434,1437,1438,1442,1443,1446,1447,1450,1451,1454,1455,1458,1459,887],{},[187,1435,1436],{},"assertIndexKeysAgree()"," checks the same for an ",[1156,1439,1441],{"href":1440},"\u002Fsearch\u002Fyour-own-client#an-index-of-your-own","index of your own",", on a model with or without ",[187,1444,1445],{},"ControlledSearchable",": for each reader, ",[187,1448,1449],{},"null"," included, the rows whose ",[187,1452,1453],{},"Access::indexKeysOf()"," values meet the ",[187,1456,1457],{},"Access::indexReaderKeys()"," values in each field must be the rows of ",[187,1460,1461],{},"controlledFor()",[179,1463,1465],{"className":181,"code":1464,"language":184,"meta":185,"style":185},"$this->assertIndexKeysAgree(PostControl::class, readers: [null, $admin, $manager, $author]);\n",[187,1466,1467],{"__ignoreMap":185},[190,1468,1469,1471,1474,1476,1478,1480,1482,1484,1486,1488,1491,1493,1495,1497,1499,1501,1503,1505,1507],{"class":192,"line":193},[190,1470,978],{"class":204},[190,1472,1473],{"class":403},"assertIndexKeysAgree",[190,1475,821],{"class":204},[190,1477,242],{"class":200},[190,1479,441],{"class":204},[190,1481,354],{"class":196},[190,1483,381],{"class":204},[190,1485,884],{"class":200},[190,1487,887],{"class":204},[190,1489,1490],{"class":204}," [null,",[190,1492,632],{"class":204},[190,1494,757],{"class":227},[190,1496,381],{"class":204},[190,1498,632],{"class":204},[190,1500,684],{"class":227},[190,1502,381],{"class":204},[190,1504,632],{"class":204},[190,1506,635],{"class":227},[190,1508,644],{"class":204},[941,1510,1511,1512,1159],{},"It runs the same clock check as ",[187,1513,1249],{},[959,1515,158],{"id":1516},"several-brands",[941,1518,1519,1522,1523,1526,1527,1159],{},[187,1520,1521],{},"assertRowContextAgrees()"," checks a parent decided in the context of the child row, with ",[187,1524,1525],{},"decidedInRowContext()",". See ",[1156,1528,162],{"href":1529},"\u002Fdigging-deeper\u002Frow-context#testing-the-switch",[959,1531,1533],{"id":1532},"kept-decisions-in-tests","Kept decisions in tests",[941,1535,1536,1537,1541,1542,1545,1546,1549,1550,1552],{},"The tests need no reset trait: the ",[1156,1538,1540],{"href":1539},"\u002Fessentials\u002Freaders#kept-decisions","kept decisions"," live in a scoped instance of the container, so each test starts with none, and every write through a Laravel connection forgets them, ",[187,1543,1544],{},"attach()"," and writes under ",[187,1547,1548],{},"Event::fake()"," included, as long as the connection was opened before ",[187,1551,1548],{},": a connection opened after it sends its events to the fake and forgets nothing.",[941,1554,1555,1556,1559,1560,1563],{},"After a permission changed in memory, such as a ",[187,1557,1558],{},"Gate::define()"," between two checks, call ",[187,1561,1562],{},"Access::forgetDecisions()"," before the next check:",[179,1565,1567],{"className":181,"code":1566,"language":184,"meta":185,"style":185},"Gate::define('update own posts', fn (User $user) => false);\nAccess::forgetDecisions();\n\n$this->assertFalse($author->can('update', $post));\n",[187,1568,1569,1610,1622,1626],{"__ignoreMap":185},[190,1570,1571,1574,1576,1579,1581,1583,1586,1588,1590,1593,1596,1598,1600,1603,1605,1607],{"class":192,"line":193},[190,1572,1573],{"class":200},"Gate",[190,1575,441],{"class":204},[190,1577,1578],{"class":403},"define",[190,1580,821],{"class":204},[190,1582,456],{"class":204},[190,1584,1585],{"class":459},"update own posts",[190,1587,456],{"class":204},[190,1589,381],{"class":204},[190,1591,1592],{"class":353}," fn",[190,1594,1595],{"class":204}," (",[190,1597,279],{"class":200},[190,1599,632],{"class":204},[190,1601,1602],{"class":227},"user",[190,1604,806],{"class":204},[190,1606,465],{"class":204},[190,1608,1609],{"class":204}," false);\n",[190,1611,1612,1614,1616,1619],{"class":192,"line":214},[190,1613,233],{"class":200},[190,1615,441],{"class":204},[190,1617,1618],{"class":403},"forgetDecisions",[190,1620,1621],{"class":204},"();\n",[190,1623,1624],{"class":192,"line":221},[190,1625,218],{"emptyLinePlaceholder":217},[190,1627,1628,1630,1633,1636,1638,1640,1643,1645,1647,1649,1651,1653,1655,1658],{"class":192,"line":247},[190,1629,978],{"class":204},[190,1631,1632],{"class":403},"assertFalse",[190,1634,1635],{"class":204},"($",[190,1637,635],{"class":227},[190,1639,638],{"class":204},[190,1641,1642],{"class":403},"can",[190,1644,821],{"class":204},[190,1646,456],{"class":204},[190,1648,1054],{"class":459},[190,1650,456],{"class":204},[190,1652,381],{"class":204},[190,1654,632],{"class":204},[190,1656,1657],{"class":227},"post",[190,1659,1660],{"class":204},"));\n",[959,1662,1664],{"id":1663},"pure-perimeter-lists-in-tests","Pure perimeter lists in tests",[941,1666,1667,1668,1671,1672,1159],{},"In tests, the package builds the perimeters of a control again each time it hands it out, and throws ",[187,1669,1670],{},"ImpurePerimetersException"," when they differ: see ",[1156,1673,34],{"href":1674},"\u002Fessentials\u002Fcontrols#pure-perimeter-lists",[941,1676,1677,1678,1681,1682,1685,1686,1688,1689,1105,1692,1695],{},"With Laravel Scout installed and without ",[187,1679,1680],{},"access:cache",", the first Eloquent write of a test, such as a factory in ",[187,1683,1684],{},"setUp()",", builds the control of every discovered ",[187,1687,1445],{}," model, to know which writes reindex which documents. Set what ",[187,1690,1691],{},"perimeters()",[187,1693,1694],{},"boundary()"," read before that first write, or read it in the callbacks.",[1697,1698,1699],"style",{},"html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}",{"title":185,"searchDepth":193,"depth":214,"links":1701},[1702,1703,1704,1707,1708,1709,1710],{"id":961,"depth":214,"text":962},{"id":1162,"depth":214,"text":1163},{"id":1243,"depth":214,"text":1244,"children":1705},[1706],{"id":1308,"depth":221,"text":1309},{"id":1430,"depth":214,"text":1431},{"id":1516,"depth":214,"text":158},{"id":1532,"depth":214,"text":1533},{"id":1663,"depth":214,"text":1664},"The InteractsWithAccess assertions prove on your test data that the levels nest, the policy and the queries agree, and the search finds what the SQL lists.","md",null,{},{"title":120,"description":1711},{"loc":121,"lastmod":1717},"2026-11-21T16:10:34+01:00","_D_bOKPaPEwp0r5nZIiNmjvyHWnqrUPfiNRfiakGH40",[1720,1722],{"title":110,"path":111,"stem":112,"description":1721,"children":-1},"With laravel-rest-api 3.6+, AccessControlExtension applies your controls to every resource of a controlled model, its text searches and row checks included.",{"title":124,"path":125,"stem":126,"description":1723,"children":-1},"php artisan access:check builds every control and reports in CI what would throw, open or hide rows, or leave search documents stale.",1795277180620]