oni-php: Add auto-insert template for Laravel test files
This commit is contained in:
parent
f2cda9c078
commit
13d38d77b8
1 changed files with 26 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue