|
83 | 83 |
|
84 | 84 | $this->assertNotNull($entry); |
85 | 85 | $this->assertSame($entry->collectionHandle(), 'comments'); |
86 | | - $this->assertSame($entry->get('title'), 'BLAH So, I was sitting there and somebody came up to me and I asked them something.'); |
87 | | - $this->assertSame($entry->slug(), 'blah-so-i-was-sitting-there-and-somebody-came-up-to-me-and-i-asked-them-something'); |
| 86 | + $this->assertSame($entry->get('title'), |
| 87 | + 'BLAH So, I was sitting there and somebody came up to me and I asked them something.'); |
| 88 | + $this->assertSame($entry->slug(), |
| 89 | + 'blah-so-i-was-sitting-there-and-somebody-came-up-to-me-and-i-asked-them-something'); |
88 | 90 | }); |
89 | 91 |
|
90 | 92 | it('can store entry with duplicate slug', function () { |
|
117 | 119 |
|
118 | 120 | $tree->tree([ |
119 | 121 | ['entry' => 'one'], |
120 | | - ['entry' => 'two', 'children' => [ |
121 | | - ['entry' => 'fantastic-one'], |
122 | | - ]], |
| 122 | + [ |
| 123 | + 'entry' => 'two', 'children' => [ |
| 124 | + ['entry' => 'fantastic-one'], |
| 125 | + ], |
| 126 | + ], |
123 | 127 | ])->save(0); |
124 | 128 |
|
125 | 129 | $this |
|
736 | 740 | '_collection' => encrypt('comments'), |
737 | 741 | 'title' => 'This is great', |
738 | 742 | 'slug' => 'this-is-great', |
739 | | - 'attachment' => UploadedFile::fake()->createWithContent('foobar.svg', '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" width="500" height="500"><script type="text/javascript">alert(`Bad stuff could go in here.`);</script></svg>'), |
| 743 | + 'attachment' => UploadedFile::fake()->createWithContent('foobar.svg', |
| 744 | + '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" width="500" height="500"><script type="text/javascript">alert(`Bad stuff could go in here.`);</script></svg>'), |
740 | 745 | ]) |
741 | 746 | ->assertRedirect(); |
742 | 747 |
|
|
1893 | 1898 | '_collection' => encrypt('albums'), |
1894 | 1899 | '_id' => encrypt('allo-mate-idee'), |
1895 | 1900 | 'record_label' => 'Unknown', |
1896 | | - 'attachment' => UploadedFile::fake()->createWithContent('foobar.svg', '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" width="500" height="500"><script type="text/javascript">alert(`Bad stuff could go in here.`);</script></svg>'), |
| 1901 | + 'attachment' => UploadedFile::fake()->createWithContent('foobar.svg', |
| 1902 | + '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" width="500" height="500"><script type="text/javascript">alert(`Bad stuff could go in here.`);</script></svg>'), |
1897 | 1903 | ]) |
1898 | 1904 | ->assertRedirect(); |
1899 | 1905 |
|
|
2399 | 2405 | $this->assertCount(2, $entry->get('things')); |
2400 | 2406 | }); |
2401 | 2407 |
|
| 2408 | +it('can update entry with replicator field in the newish way', function () { |
| 2409 | + Blueprint::make('albums') |
| 2410 | + ->setNamespace('collections.albums') |
| 2411 | + ->setContents([ |
| 2412 | + 'tabs' => [ |
| 2413 | + 'main' => [ |
| 2414 | + 'display' => 'Hauptteil', |
| 2415 | + 'sections' => [ |
| 2416 | + [ |
| 2417 | + 'fields' => [ |
| 2418 | + [ |
| 2419 | + 'handle' => 'title', |
| 2420 | + 'field' => [ |
| 2421 | + 'type' => 'text', |
| 2422 | + 'validate' => ['required'], |
| 2423 | + ], |
| 2424 | + ], |
| 2425 | + ], |
| 2426 | + ], |
| 2427 | + [ |
| 2428 | + 'fields' => [ |
| 2429 | + [ |
| 2430 | + 'handle' => 'category', |
| 2431 | + 'field' => [ |
| 2432 | + 'type' => 'replicator', |
| 2433 | + 'display' => 'Kategorie / Seite', |
| 2434 | + 'sets' => [ |
| 2435 | + 'category' => [ |
| 2436 | + 'display' => 'Kategorie / Seite', |
| 2437 | + 'sets' => [ |
| 2438 | + 'category' => [ |
| 2439 | + 'display' => 'Kategorie / Seite', |
| 2440 | + 'fields' => [ |
| 2441 | + [ |
| 2442 | + 'handle' => 'name', |
| 2443 | + 'field' => [ |
| 2444 | + 'type' => 'text', |
| 2445 | + 'display' => 'Name', |
| 2446 | + ], |
| 2447 | + ], |
| 2448 | + [ |
| 2449 | + 'handle' => 'checklist', |
| 2450 | + 'field' => [ |
| 2451 | + 'type' => 'grid', |
| 2452 | + 'display' => 'Checkliste', |
| 2453 | + 'mode' => 'stacked', |
| 2454 | + 'fields' => [ |
| 2455 | + [ |
| 2456 | + 'handle' => 'hl', |
| 2457 | + 'field' => [ |
| 2458 | + 'type' => 'text', |
| 2459 | + 'display' => 'Überschrift', |
| 2460 | + 'localizable' => false, |
| 2461 | + 'width' => 75, |
| 2462 | + ], |
| 2463 | + ], |
| 2464 | + [ |
| 2465 | + 'handle' => 'is_done', |
| 2466 | + 'field' => [ |
| 2467 | + 'type' => 'toggle', |
| 2468 | + 'display' => 'Erledigt', |
| 2469 | + 'localizable' => false, |
| 2470 | + 'width' => 25, |
| 2471 | + ], |
| 2472 | + ], |
| 2473 | + [ |
| 2474 | + 'handle' => 'description', |
| 2475 | + 'field' => [ |
| 2476 | + 'type' => 'textarea', |
| 2477 | + 'display' => 'Beschreibung', |
| 2478 | + 'localizable' => false, |
| 2479 | + ], |
| 2480 | + ], |
| 2481 | + ], |
| 2482 | + ], |
| 2483 | + ], |
| 2484 | + ], |
| 2485 | + ], |
| 2486 | + ], |
| 2487 | + ], |
| 2488 | + ], |
| 2489 | + ], |
| 2490 | + ], |
| 2491 | + ], |
| 2492 | + ], |
| 2493 | + ], |
| 2494 | + ], |
| 2495 | + ], |
| 2496 | + 'title' => 'Checklist', |
| 2497 | + ]) |
| 2498 | + ->save(); |
| 2499 | + |
| 2500 | + Collection::make('albums')->save(); |
| 2501 | + |
| 2502 | + Entry::make() |
| 2503 | + ->id('allo-mate-idee') |
| 2504 | + ->collection('albums') |
| 2505 | + ->slug('allo-mate') |
| 2506 | + ->data([ |
| 2507 | + 'title' => 'Allo Mate!', |
| 2508 | + 'category' => [ |
| 2509 | + [ |
| 2510 | + 'id' => 'mfzefa0t', |
| 2511 | + 'name' => 'Home', |
| 2512 | + 'checklist' => [ |
| 2513 | + [ |
| 2514 | + 'id' => 'mfzefj0y', |
| 2515 | + 'hl' => 'Actionbild', |
| 2516 | + 'description' => 'Test', |
| 2517 | + 'is_done' => true, |
| 2518 | + ], |
| 2519 | + [ |
| 2520 | + 'id' => 'mfzg61ls', |
| 2521 | + 'hl' => 'asdsfgsdg', |
| 2522 | + 'description' => 'dfdfdfg', |
| 2523 | + ], |
| 2524 | + ], |
| 2525 | + 'type' => 'category', |
| 2526 | + 'enabled' => true, |
| 2527 | + ], |
| 2528 | + [ |
| 2529 | + 'id' => 'mfzg64m6', |
| 2530 | + 'name' => 'Leistungen', |
| 2531 | + 'checklist' => [ |
| 2532 | + [ |
| 2533 | + 'id' => 'mfzg68ik', |
| 2534 | + 'hl' => 'dfgdfgfd', |
| 2535 | + 'is_done' => true, |
| 2536 | + 'description' => 'dfgfdgfdg', |
| 2537 | + ], |
| 2538 | + [ |
| 2539 | + 'id' => 'mfzg6d0f', |
| 2540 | + 'hl' => 'gfhgfhgfh', |
| 2541 | + 'description' => 'asddfggfdg', |
| 2542 | + ], |
| 2543 | + ], |
| 2544 | + 'type' => 'category', |
| 2545 | + 'enabled' => true, |
| 2546 | + ], |
| 2547 | + ], |
| 2548 | + ]) |
| 2549 | + ->save(); |
| 2550 | + |
| 2551 | + $this |
| 2552 | + ->post(route('statamic.guest-entries.update'), [ |
| 2553 | + '_collection' => encrypt('albums'), |
| 2554 | + '_id' => encrypt('allo-mate-idee'), |
| 2555 | + 'category' => [ |
| 2556 | + [ |
| 2557 | + 'id' => 'mfzefa0t', |
| 2558 | + 'name' => 'Home', |
| 2559 | + 'checklist' => [ |
| 2560 | + ['id' => 'mfzefj0y', 'hl' => 'Actionbild', 'description' => 'Test', 'is_done' => true], |
| 2561 | + ['id' => 'mfzg61ls', 'hl' => 'asdsfgsdg', 'description' => 'dfdfdfg'], |
| 2562 | + ], |
| 2563 | + // 'type' => 'category', |
| 2564 | + 'enabled' => true, |
| 2565 | + ], |
| 2566 | + [ |
| 2567 | + 'id' => 'mfzg64m6', |
| 2568 | + 'name' => 'Leistungen', |
| 2569 | + 'checklist' => [ |
| 2570 | + ['id' => 'mfzg68ik', 'hl' => 'dfgdfgfd', 'description' => 'dfgfdgfdg'], |
| 2571 | + ['id' => 'mfzg6d0f', 'hl' => 'gfhgfhgfh', 'description' => 'asddfggfdg'], |
| 2572 | + ], |
| 2573 | + // 'type' => 'category', |
| 2574 | + 'enabled' => true, |
| 2575 | + ], |
| 2576 | + ], |
| 2577 | + ]) |
| 2578 | + ->assertRedirect(); |
| 2579 | + |
| 2580 | + $entry = Entry::find('allo-mate-idee'); |
| 2581 | + |
| 2582 | + $this->assertNotNull($entry); |
| 2583 | + $this->assertSame($entry->collectionHandle(), 'albums'); |
| 2584 | + |
| 2585 | + $this->assertCount(2, $entry->get('category')); |
| 2586 | + |
| 2587 | + $this->assertEquals([ |
| 2588 | + [ |
| 2589 | + 'id' => 'mfzefa0t', |
| 2590 | + 'name' => 'Home', |
| 2591 | + 'checklist' => [ |
| 2592 | + [ |
| 2593 | + 'id' => 'mfzefj0y', |
| 2594 | + 'hl' => 'Actionbild', |
| 2595 | + 'description' => 'Test', |
| 2596 | + 'is_done' => true, |
| 2597 | + ], |
| 2598 | + [ |
| 2599 | + 'id' => 'mfzg61ls', |
| 2600 | + 'hl' => 'asdsfgsdg', |
| 2601 | + 'description' => 'dfdfdfg', |
| 2602 | + ], |
| 2603 | + ], |
| 2604 | + 'type' => 'category', |
| 2605 | + 'enabled' => true, |
| 2606 | + ], |
| 2607 | + [ |
| 2608 | + 'id' => 'mfzg64m6', |
| 2609 | + 'name' => 'Leistungen', |
| 2610 | + 'checklist' => [ |
| 2611 | + [ |
| 2612 | + // This one used to have "is_done" set to true, but we unset it in the request. |
| 2613 | + 'id' => 'mfzg68ik', |
| 2614 | + 'hl' => 'dfgdfgfd', |
| 2615 | + 'description' => 'dfgfdgfdg', |
| 2616 | + ], |
| 2617 | + [ |
| 2618 | + 'id' => 'mfzg6d0f', |
| 2619 | + 'hl' => 'gfhgfhgfh', |
| 2620 | + 'description' => 'asddfggfdg', |
| 2621 | + ], |
| 2622 | + ], |
| 2623 | + 'type' => 'category', |
| 2624 | + 'enabled' => true, |
| 2625 | + ], |
| 2626 | + ], $entry->get('category')); |
| 2627 | +}); |
| 2628 | + |
2402 | 2629 | it('can update entry with replicator field and an assets field inside the replicator', function () { |
2403 | 2630 | Blueprint::make('albums') |
2404 | 2631 | ->setNamespace('collections.albums') |
|
0 commit comments