aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--oni-php/oni-php.el27
1 files changed, 26 insertions, 1 deletions
diff --git a/oni-php/oni-php.el b/oni-php/oni-php.el
index 36394da..22e3ef5 100644
--- a/oni-php/oni-php.el
+++ b/oni-php/oni-php.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2025.0407.141956
+;; Version: 2025.0415.154414
;; Package-Requires: (php-mode oni-yasnippet oni-flycheck oni-company oni-hydra oni-smartparens ggtags fic-mode company-php rainbow-delimiters)
;; This program is free software; you can redistribute it and/or modify
@@ -205,5 +205,30 @@ Otherwise call FUNC with ARGS. This is meant as advice around
(with-eval-after-load 'grep
(add-to-list 'grep-files-aliases '("php" . "*.php *.inc *.module")))
+(with-eval-after-load 'autoinsert
+ (setf (map-elt auto-insert-alist (rx "Test.php" eos))
+ '(nil
+ "<?php\n"
+ "\n"
+ "declare(strict_types=1);\n"
+ "\n"
+ "namespace " (string-join (mapcar #'capitalize (cdr (split-string (directory-file-name (file-name-directory (file-relative-name buffer-file-name (project-root (project-current))))) "/"))) "\\") ";\n"
+ "\n"
+ "use Illuminate\\Foundation\\Testing\\RefreshDatabase;\n"
+ "use Illuminate\\Foundation\\Testing\\WithFaker;\n"
+ "use Tests\\TestCase;\n"
+ "\n"
+ "class " (file-name-sans-extension (file-name-nondirectory (buffer-file-name))) " extends TestCase\n"
+ "{\n"
+ > "use RefreshDatabase;\n"
+ > "use WithFaker;\n"
+ "\n"
+ > "/** @test */\n"
+ > "public function " (replace-regexp-in-string (rx whitespace) "_" (downcase (skeleton-read "Test function name: "))) "(): void\n"
+ "{" > "\n"
+ > _ "\n"
+ "}" > "\n"
+ "}")))
+
(provide 'oni-php)
;;; oni-php.el ends here