TestTable.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. declare(strict_types=1);
  3. namespace TestApp\Model\Table;
  4. use Cake\ORM\Query\SelectQuery;
  5. use Cake\ORM\Table;
  6. /**
  7. * A Test double used to assert that default tables are created
  8. */
  9. class TestTable extends Table
  10. {
  11. public mixed $first;
  12. public array $variadic;
  13. public array $variadicOptions;
  14. /**
  15. * @param array $config
  16. */
  17. public function initialize(array $config): void
  18. {
  19. $this->setSchema(['id' => ['type' => 'integer']]);
  20. }
  21. public function findPublishedWithArgOnly(SelectQuery $query, string $what = 'worked', mixed $other = null): SelectQuery
  22. {
  23. return $query->applyOptions(['this' => $what]);
  24. }
  25. public function findWithOptions(SelectQuery $query, array $options): SelectQuery
  26. {
  27. return $query->applyOptions(['this' => 'worked']);
  28. }
  29. public function findVariadicOptions(SelectQuery $query, ...$options): SelectQuery
  30. {
  31. $this->variadicOptions = $options;
  32. return $query;
  33. }
  34. public function findVariadic(SelectQuery $query, mixed $first = null, mixed ...$variadic): SelectQuery
  35. {
  36. $this->first = $first;
  37. $this->variadic = $variadic;
  38. return $query;
  39. }
  40. }