├── .editorconfig ├── .github ├── FUNDING.yml └── workflows │ ├── default.yml │ └── stale.yml ├── .gitignore ├── .vscode ├── extensions.json └── settings.json ├── LICENSE ├── README.md ├── codeception.yml ├── composer.json ├── composer.lock ├── src └── Assets.php └── tests ├── _data ├── .gitkeep ├── assets │ ├── demo.deadbeef.css │ ├── index.deadbeef.css │ ├── index.deadbeef.js │ └── vendor.deadbeef.js └── manifest.json ├── _output ├── .gitignore └── .gitkeep ├── _support ├── .gitkeep ├── Helper │ └── Unit.php ├── UnitTester.php └── _generated │ ├── .gitignore │ └── UnitTesterActions.php ├── unit.suite.yml └── unit └── WordpressViteAssetsTest.php /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.{yml,yaml}] 12 | indent_style = space 13 | 14 | [*.{js,ts}] 15 | block_comment_start = /* 16 | block_comment = * 17 | block_comment_end = */ 18 | 19 | [*.{markdown,md}] 20 | trim_trailing_whitespace = false 21 | 22 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | buy_me_a_coffee: idleberg 2 | -------------------------------------------------------------------------------- /.github/workflows/default.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - ".github/**" 7 | - "src/**" 8 | - "tests/**" 9 | - "composer.lock" 10 | pull_request: 11 | paths: 12 | - ".github/**" 13 | - "src/**" 14 | - "tests/**" 15 | - "composer.lock" 16 | workflow_dispatch: 17 | 18 | jobs: 19 | run: 20 | runs-on: ${{ matrix.operating-system }} 21 | strategy: 22 | matrix: 23 | operating-system: [ubuntu-latest] 24 | php-versions: ["8.1", "8.2", "8.3", "8.4"] 25 | name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} 26 | env: 27 | extensions: intl, pcov 28 | key: cache-v1 # can be any string, change to clear the extension cache. 29 | steps: 30 | - name: Checkout 31 | uses: actions/checkout@v4 32 | 33 | - name: Setup cache environment 34 | id: extcache 35 | uses: shivammathur/cache-extensions@v1 36 | with: 37 | php-version: ${{ matrix.php-versions }} 38 | extensions: ${{ env.extensions }} 39 | key: ${{ env.key }} 40 | 41 | - name: Cache extensions 42 | uses: actions/cache@v4 43 | with: 44 | path: ${{ steps.extcache.outputs.dir }} 45 | key: ${{ steps.extcache.outputs.key }} 46 | restore-keys: ${{ steps.extcache.outputs.key }} 47 | 48 | - name: Setup PHP 49 | uses: shivammathur/setup-php@v2 50 | with: 51 | php-version: ${{ matrix.php-versions }} 52 | extensions: ${{ env.extensions }} 53 | 54 | - name: Dependencies 55 | run: composer update 56 | 57 | - name: Lint 58 | run: composer run lint 59 | 60 | - name: Test 61 | run: composer run test 62 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: 'Stale issues and PR' 2 | on: 3 | schedule: 4 | - cron: '30 1 * * *' 5 | 6 | jobs: 7 | stale: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/stale@v4 11 | with: 12 | stale-issue-label: stale 13 | stale-pr-label: stale 14 | stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 14 days.' 15 | stale-pr-message: 'This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 14 days.' 16 | close-issue-message: 'This issue was closed because it has been stalled for 14 days with no activity.' 17 | close-pr-message: 'This PR was closed because it has been stalled for 14 days with no activity.' 18 | days-before-issue-stale: 90 19 | days-before-pr-stale: 90 20 | days-before-issue-close: 30 21 | days-before-pr-close: 30 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | vendor/ 3 | 4 | # project specific 5 | .php-cs-fixer.cache 6 | ./test.php 7 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["devsense.phptools-vscode", "editorconfig.editorconfig"] 3 | } 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnPaste": true, 3 | "editor.formatOnSave": true, 4 | "[php]": { 5 | "editor.defaultFormatter": "devsense.phptools-vscode" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2022-2025 Jan T. Sott & contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vite Assets for WordPress 2 | 3 | > Adds assets from a [Vite](https://vitejs.dev/) manifest to the WordPress head, supports themes and plugins. 4 | 5 | [![License](https://img.shields.io/packagist/l/idleberg/wordpress-vite-assets?style=for-the-badge&color=blue)](https://github.com/idleberg/php-wordpress-vite-assets/blob/main/LICENSE) 6 | [![Version](https://img.shields.io/packagist/v/idleberg/wordpress-vite-assets?style=for-the-badge)](https://github.com/idleberg/php-wordpress-vite-assets/releases) 7 | ![PHP Version](https://img.shields.io/packagist/dependency-v/idleberg/wordpress-vite-assets/php?style=for-the-badge) 8 | [![Build](https://img.shields.io/github/actions/workflow/status/idleberg/php-wordpress-vite-assets/default.yml?style=for-the-badge)](https://github.com/idleberg/php-wordpress-vite-assets/actions) 9 | 10 | 11 | **Table of contents** 12 | 13 | - [Installation](#installation) 14 | - [Usage](#usage) 15 | - [Methods](#methods) 16 | - [`inject()`](#inject) 17 | - [`getScriptTag()`](#getscripttag) 18 | - [`getStyleTags()`](#getstyletags) 19 | - [`getPreloadTags()`](#getpreloadtags) 20 | - [Options](#options) 21 | - [`option.action`](#optionaction) 22 | - [`option.crossorigin`](#optioncrossorigin) 23 | - [`option.integrity`](#optionintegrity) 24 | - [`option.priority`](#optionpriority) 25 | - [License](#license) 26 | 27 | ## Installation 28 | 29 | `composer require idleberg/wordpress-vite-assets` 30 | 31 | ## Usage 32 | 33 | To get you going, first instantiate the class exposed by this library 34 | 35 | ```php 36 | new Assets(string $manifestPath, string $baseUri, string $algorithm = "sha256"); 37 | ``` 38 | 39 | ### Parameters 40 | 41 | #### `$manifestPath` 42 | 43 | Type: `string` 44 | 45 | Specifies the path to the manifest. 46 | 47 | #### `$baseUri` 48 | 49 | Type: `string` 50 | 51 | Specifies the base URI for the assets in the manifest. 52 | 53 | #### `$algorithm` 54 | 55 | Type: `"sha256"` |`"sha384"` |`"sha512"` | `":manifest:"` 56 | Default: `"sha256"` 57 | 58 | Specifies the algorithm used for hashing the assets. This will be used for [subsource integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) when printing script or style tags. 59 | 60 | > [!TIP] 61 | > You can use `":manifest:"` in conjunction with [vite-plugin-manifest-sri](https://github.com/ElMassimo/vite-plugin-manifest-sri), a plug-in that calculates the hashes at build-time and adds them to the manifest. 62 | 63 | **Example** 64 | 65 | ```php 66 | // functions.php 67 | 68 | use Idleberg\WordPress\ViteAssets\Assets; 69 | 70 | $baseUrl = get_stylesheet_directory_uri(); 71 | $manifest = "path/to/manifest.json"; 72 | $entryPoint = "index.ts"; 73 | 74 | $viteAssets = new Assets($manifest, $baseUrl); 75 | $viteAssets->inject($entryPoint); 76 | ``` 77 | 78 | ### Methods 79 | 80 | #### `inject()` 81 | 82 | Usage: `inject(array|string $entrypoints, array $options = [])` 83 | 84 | Injects tags for entries specified in the manifest to the page header 85 | 86 | - script entrypoint 87 | - preloads for imported scripts 88 | - style tags 89 | 90 | #### `getScriptTag()` 91 | 92 | Usage: `getScriptTag(string $entrypoint, array $options = [])` 93 | 94 | Returns the script tag for an entry in the manifest 95 | 96 | #### `getStyleTags()` 97 | 98 | Usage: `getStyleTags(string $entrypoint, array $options = [])` 99 | 100 | Returns the style tags for an entry in the manifest 101 | 102 | #### `getPreloadTags()` 103 | 104 | Usage: `getPreloadTags(string $entrypoint)` 105 | 106 | Returns the preload tags for an entry in the manifest 107 | 108 | ### Options 109 | 110 | #### `option.action` 111 | 112 | Type: `null | string` 113 | 114 | Allows overriding the default action for the [`inject()`](#inject) method. 115 | 116 | > [!WARNING] 117 | > It's unlikely that you want to change the default action, so don't override unless you know what you're doing! 118 | 119 | **Example** 120 | 121 | ```php 122 | // plugin.php 123 | 124 | $viteAssets->inject("index.ts", [ 125 | "action" => "admin_head" 126 | ]); 127 | ``` 128 | 129 | #### `option.crossorigin` 130 | 131 | Type: `boolean | "anonymous" | "use-credentials"` 132 | 133 | Toggles `crossorigin` attribute on script and style tags, or assigns a value 134 | 135 | #### `option.integrity` 136 | 137 | Type: `boolean` 138 | 139 | Toggles `integrity` attribute on script and style tags 140 | 141 | #### `option.priority` 142 | 143 | Type: `int | array` 144 | 145 | Allows overriding the priority for the [`inject()`](#inject) method. It allows granular control when provided as an array: 146 | 147 | **Example** 148 | 149 | ```php 150 | // functions.php 151 | 152 | $viteAssets->inject("index.ts", [ 153 | "priority" => [ 154 | "scripts" => 10, 155 | "preloads" => 0, 156 | "styles" => 20 157 | ] 158 | ]); 159 | ``` 160 | 161 | ## License 162 | 163 | This work is licensed under [The MIT License](LICENSE). 164 | -------------------------------------------------------------------------------- /codeception.yml: -------------------------------------------------------------------------------- 1 | paths: 2 | tests: tests 3 | output: tests/_output 4 | data: tests/_data 5 | support: tests/_support 6 | envs: tests/_envs 7 | actor_suffix: Tester 8 | extensions: 9 | enabled: 10 | - Codeception\Extension\RunFailed 11 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "idleberg/wordpress-vite-assets", 3 | "description": "Injects assets from a Vite manifest to the Wordpress head, supports themes and plugins", 4 | "type": "library", 5 | "license": "MIT", 6 | "keywords": [ 7 | "wordpress", 8 | "vite", 9 | "vitejs", 10 | "vite manifest" 11 | ], 12 | "minimum-stability": "dev", 13 | "prefer-stable": true, 14 | "autoload": { 15 | "psr-4": { 16 | "Idleberg\\WordPress\\ViteAssets\\": "src/" 17 | } 18 | }, 19 | "authors": [ 20 | { 21 | "name": "Jan T. Sott", 22 | "email": "idleberg@users.noreply.github.com" 23 | } 24 | ], 25 | "require": { 26 | "php": ">=8.1", 27 | "idleberg/vite-manifest": "^1.2.2" 28 | }, 29 | "require-dev": { 30 | "codeception/codeception": "^5.0.4", 31 | "codeception/module-asserts": "^3.0.0", 32 | "friendsofphp/php-cs-fixer": "^3.11", 33 | "phpstan/phpstan": "^1.9", 34 | "phpstan/extension-installer": "^1.2", 35 | "szepeviktor/phpstan-wordpress": "^1.1", 36 | "brainmaestro/composer-git-hooks": "^3.0.0", 37 | "shipmonk/composer-dependency-analyser": "^1.6", 38 | "ramsey/conventional-commits": "^1.6" 39 | }, 40 | "scripts": { 41 | "format": "vendor/bin/php-cs-fixer fix ./src", 42 | "lint": "php -l ./src", 43 | "test": [ 44 | "vendor/bin/phpstan analyse ./src --memory-limit=512M --level 5", 45 | "vendor/bin/codecept run" 46 | ], 47 | "unused": "vendor/bin/composer-dependency-analyser" 48 | }, 49 | "config": { 50 | "allow-plugins": { 51 | "phpstan/extension-installer": true 52 | } 53 | }, 54 | "extra": { 55 | "hooks": { 56 | "config": { 57 | "stop-on-failure": [ 58 | "commit-msg", 59 | "pre-commit" 60 | ] 61 | }, 62 | "commit-msg": [ 63 | "./vendor/bin/conventional-commits validate $1" 64 | ], 65 | "pre-commit": [ 66 | "composer run format", 67 | "composer run lint", 68 | "composer run unused" 69 | ] 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Assets.php: -------------------------------------------------------------------------------- 1 | null, 34 | "crossorigin" => true, 35 | "integrity" => true, 36 | "priority" => 0 37 | ]; 38 | 39 | public function __construct(string $manifestFile, string $basePath, string $algorithm = "sha256") 40 | { 41 | // Let ViteManifest handle errors 42 | $this->vm = new Manifest($manifestFile, $basePath, $algorithm); 43 | } 44 | 45 | /** 46 | * Injects tags for entries specified in the manifest to the page header. 47 | * 48 | * @param array|string $entrypoint 49 | * @param array $customOptions (optional) 50 | * @return void 51 | */ 52 | public function inject(array|string $entrypoint, array $customOptions = []): void 53 | { 54 | if (!function_exists('add_action')) { 55 | throw new \Exception("WordPress function add_action() not found"); 56 | } 57 | 58 | $options = $this->mergeOptions($customOptions); 59 | ["action" => $action, "priority" => $priority] = $options; 60 | 61 | if ($action === null || !is_string($action)) { 62 | $action = is_admin() ? 'admin_head' : 'wp_head'; 63 | } 64 | 65 | if (!has_action($action)) { 66 | throw new \Exception("The hook '$action' could not be found"); 67 | } 68 | 69 | $entries = is_array($entrypoint) ? $entrypoint : [$entrypoint]; 70 | 71 | add_action($action, function () use ($entries, $options) { 72 | array_map(function ($entry) use ($options) { 73 | $tag = $this->isStylesheet($entry) 74 | ? array_key_first($this->getStyleTags($entry, $options)) 75 | : $this->getScriptTag($entry, $options); 76 | 77 | if ($tag) { 78 | echo $tag . PHP_EOL; 79 | } 80 | }, $entries); 81 | }, $this->getPriority($priority, "scripts"), 1); 82 | 83 | add_action($action, function () use ($entries) { 84 | array_map(function ($entry) { 85 | array_map(function ($preloadTag) { 86 | echo $preloadTag . PHP_EOL; 87 | }, $this->getPreloadTags($entry)); 88 | }, $entries); 89 | }, $this->getPriority($priority, "preloads"), 1); 90 | 91 | add_action($action, function () use ($entries, $options) { 92 | array_map(function ($entry) use ($options) { 93 | array_map(function ($styleTag) { 94 | echo $styleTag . PHP_EOL; 95 | }, $this->getStyleTags($entry, $options)); 96 | }, $entries); 97 | }, $this->getPriority($priority, "styles"), 1); 98 | } 99 | 100 | /** 101 | * Returns the script tag for an entry in the manifest. 102 | * 103 | * @param string $entrypoint 104 | * @param array $customOptions (optional) 105 | * @return string 106 | */ 107 | public function getScriptTag(string $entrypoint, array $customOptions = []): string 108 | { 109 | $options = $this->mergeOptions($customOptions); 110 | $hash = $options["integrity"] ?? true; 111 | $url = $this->vm->getEntrypoint($entrypoint, $hash); 112 | 113 | if (!$url) { 114 | return ""; 115 | } 116 | 117 | $defaultAttributes = [ 118 | "type=\"module\"", 119 | "src=\"{$url['url']}\"" 120 | ]; 121 | 122 | return ""; 123 | } 124 | 125 | /** 126 | * Returns the style tags for an entry in the manifest. 127 | * 128 | * @param string $entrypoint 129 | * @param array $customOptions (optional) 130 | * @return array 131 | */ 132 | public function getStyleTags(string $entrypoint, array $customOptions = []): array 133 | { 134 | $options = $this->mergeOptions($customOptions); 135 | $hash = $options["integrity"] ?? true; 136 | 137 | return array_map(function ($url) use ($options) { 138 | $defaultAttributes = [ 139 | "rel=\"stylesheet\"", 140 | "href=\"{$url['url']}\"" 141 | ]; 142 | 143 | return "getAttributes($url, $defaultAttributes, $options)} />"; 144 | }, $this->vm->getStyles($entrypoint, $hash)); 145 | } 146 | 147 | /** 148 | * Returns the preload tags for an entry in the manifest. 149 | * 150 | * @param string $entry 151 | * @return array 152 | */ 153 | public function getPreloadTags(string $entry): array 154 | { 155 | return array_map(function ($import) { 156 | return ""; 157 | }, $this->vm->getImports($entry)); 158 | } 159 | 160 | /** 161 | * Returns priority for an action. 162 | * 163 | * @param array|int $priority 164 | * @param string $key 165 | * @return int 166 | */ 167 | private function getPriority(array|int $priority, string $key) 168 | { 169 | switch (true) { 170 | case is_integer($priority): 171 | return $priority; 172 | 173 | case is_array($priority) && is_integer($priority[$key]): 174 | return $priority[$key]; 175 | 176 | default: 177 | return 0; 178 | } 179 | } 180 | 181 | /** 182 | * Returns optional attributes for script or link tags. 183 | * 184 | * @param array $url 185 | * @param array $attributes 186 | * @param array $customOptions 187 | * @return string 188 | */ 189 | private function getAttributes(array $url, array $attributes, array $customOptions) 190 | { 191 | ["crossorigin" => $crossorigin, "integrity" => $integrity] = $this->mergeOptions($customOptions); 192 | 193 | if ($crossorigin === true) { 194 | $attributes[] = "crossorigin"; 195 | } elseif (in_array($crossorigin, ["anonymous", "use-credentials"])) { 196 | $attributes[] = "crossorigin=\"{$crossorigin}\""; 197 | } 198 | 199 | if ($integrity === true) { 200 | $attributes[] = "integrity=\"{$url['hash']}\""; 201 | } 202 | 203 | return join(" ", $attributes); 204 | } 205 | 206 | /** 207 | * Merges custom options with defaults. 208 | * 209 | * @param array $options (optional) 210 | * @return array 211 | */ 212 | private function mergeOptions(array $options = []) 213 | { 214 | return array_merge( 215 | $this->defaultOptions, 216 | $options 217 | ); 218 | } 219 | 220 | /** 221 | * Determines whether a file is a stylesheet based on its extension. 222 | * 223 | * @param string $entry 224 | * @return bool 225 | */ 226 | private function isStylesheet(string $entry) 227 | { 228 | $styleSheets = ['.css', '.less', '.scss', '.styl']; 229 | 230 | return in_array(pathinfo($entry, PATHINFO_EXTENSION), $styleSheets); 231 | } 232 | } 233 | -------------------------------------------------------------------------------- /tests/_data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idleberg/php-wordpress-vite-assets/f14f44cf6c3897c10d98ce648d473cc1c5d957f4/tests/_data/.gitkeep -------------------------------------------------------------------------------- /tests/_data/assets/demo.deadbeef.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --deadbeef: '#deadbeef'; 3 | } 4 | -------------------------------------------------------------------------------- /tests/_data/assets/index.deadbeef.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --deadbeef: '#deadbeef'; 3 | } 4 | -------------------------------------------------------------------------------- /tests/_data/assets/index.deadbeef.js: -------------------------------------------------------------------------------- 1 | console.log('deadbeef'); 2 | -------------------------------------------------------------------------------- /tests/_data/assets/vendor.deadbeef.js: -------------------------------------------------------------------------------- 1 | console.log('vendor:deadbeef'); 2 | -------------------------------------------------------------------------------- /tests/_data/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "demo.ts": { 3 | "file": "assets/index.deadbeef.js", 4 | "src": "demo.ts", 5 | "isEntry": true, 6 | "imports": [ 7 | "vendor.deadbeef.js" 8 | ], 9 | "css": [ 10 | "assets/index.deadbeef.css" 11 | ] 12 | }, 13 | "vendor.deadbeef.js": { 14 | "file": "assets/vendor.deadbeef.js" 15 | }, 16 | "demo.css": { 17 | "file": "assets/demo.deadbeef.css", 18 | "isEntry": true, 19 | "src": "demo.css" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/_output/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /tests/_output/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idleberg/php-wordpress-vite-assets/f14f44cf6c3897c10d98ce648d473cc1c5d957f4/tests/_output/.gitkeep -------------------------------------------------------------------------------- /tests/_support/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/idleberg/php-wordpress-vite-assets/f14f44cf6c3897c10d98ce648d473cc1c5d957f4/tests/_support/.gitkeep -------------------------------------------------------------------------------- /tests/_support/Helper/Unit.php: -------------------------------------------------------------------------------- 1 | expectThrowable(MyThrowable::class, function() { 25 | * $this->doSomethingBad(); 26 | * }); 27 | * 28 | * $I->expectThrowable(new MyException(), function() { 29 | * $this->doSomethingBad(); 30 | * }); 31 | * ``` 32 | * 33 | * If you want to check message or throwable code, you can pass them with throwable instance: 34 | * ```php 35 | * expectThrowable(new MyError("Don't do bad things"), function() { 38 | * $this->doSomethingBad(); 39 | * }); 40 | * ``` 41 | * @see \Codeception\Module\Asserts::expectThrowable() 42 | */ 43 | public function expectThrowable(\Throwable|string $throwable, callable $callback): void { 44 | $this->getScenario()->runStep(new \Codeception\Step\Action('expectThrowable', func_get_args())); 45 | } 46 | 47 | 48 | /** 49 | * [!] Method is generated. Documentation taken from corresponding module. 50 | * 51 | * Asserts that a file does not exist. 52 | * @see \Codeception\Module\AbstractAsserts::assertFileNotExists() 53 | */ 54 | public function assertFileNotExists(string $filename, string $message = "") { 55 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotExists', func_get_args())); 56 | } 57 | 58 | 59 | /** 60 | * [!] Method is generated. Documentation taken from corresponding module. 61 | * 62 | * Asserts that a value is greater than or equal to another value. 63 | * 64 | * @param mixed $expected 65 | * @param mixed $actual 66 | * @see \Codeception\Module\AbstractAsserts::assertGreaterOrEquals() 67 | */ 68 | public function assertGreaterOrEquals($expected, $actual, string $message = "") { 69 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterOrEquals', func_get_args())); 70 | } 71 | 72 | 73 | /** 74 | * [!] Method is generated. Documentation taken from corresponding module. 75 | * 76 | * Asserts that a variable is empty. 77 | * 78 | * @param mixed $actual 79 | * @see \Codeception\Module\AbstractAsserts::assertIsEmpty() 80 | */ 81 | public function assertIsEmpty($actual, string $message = "") { 82 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsEmpty', func_get_args())); 83 | } 84 | 85 | 86 | /** 87 | * [!] Method is generated. Documentation taken from corresponding module. 88 | * 89 | * Asserts that a value is smaller than or equal to another value. 90 | * 91 | * @param mixed $expected 92 | * @param mixed $actual 93 | * @see \Codeception\Module\AbstractAsserts::assertLessOrEquals() 94 | */ 95 | public function assertLessOrEquals($expected, $actual, string $message = "") { 96 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessOrEquals', func_get_args())); 97 | } 98 | 99 | 100 | /** 101 | * [!] Method is generated. Documentation taken from corresponding module. 102 | * 103 | * Asserts that a string does not match a given regular expression. 104 | * @see \Codeception\Module\AbstractAsserts::assertNotRegExp() 105 | */ 106 | public function assertNotRegExp(string $pattern, string $string, string $message = "") { 107 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotRegExp', func_get_args())); 108 | } 109 | 110 | 111 | /** 112 | * [!] Method is generated. Documentation taken from corresponding module. 113 | * 114 | * Asserts that a string matches a given regular expression. 115 | * @see \Codeception\Module\AbstractAsserts::assertRegExp() 116 | */ 117 | public function assertRegExp(string $pattern, string $string, string $message = "") { 118 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertRegExp', func_get_args())); 119 | } 120 | 121 | 122 | /** 123 | * [!] Method is generated. Documentation taken from corresponding module. 124 | * 125 | * Evaluates a PHPUnit\Framework\Constraint matcher object. 126 | * 127 | * @param mixed $value 128 | * @see \Codeception\Module\AbstractAsserts::assertThatItsNot() 129 | */ 130 | public function assertThatItsNot($value, \PHPUnit\Framework\Constraint\Constraint $constraint, string $message = "") { 131 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertThatItsNot', func_get_args())); 132 | } 133 | 134 | 135 | /** 136 | * [!] Method is generated. Documentation taken from corresponding module. 137 | * 138 | * Asserts that an array has a specified key. 139 | * 140 | * @param int|string $key 141 | * @param array|\ArrayAccess $array 142 | * @see \Codeception\Module\AbstractAsserts::assertArrayHasKey() 143 | */ 144 | public function assertArrayHasKey($key, $array, string $message = "") { 145 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayHasKey', func_get_args())); 146 | } 147 | 148 | 149 | /** 150 | * [!] Method is generated. Documentation taken from corresponding module. 151 | * 152 | * Asserts that an array does not have a specified key. 153 | * 154 | * @param int|string $key 155 | * @param array|\ArrayAccess $array 156 | * @see \Codeception\Module\AbstractAsserts::assertArrayNotHasKey() 157 | */ 158 | public function assertArrayNotHasKey($key, $array, string $message = "") { 159 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayNotHasKey', func_get_args())); 160 | } 161 | 162 | 163 | /** 164 | * [!] Method is generated. Documentation taken from corresponding module. 165 | * 166 | * Asserts that a class has a specified attribute. 167 | * @see \Codeception\Module\AbstractAsserts::assertClassHasAttribute() 168 | */ 169 | public function assertClassHasAttribute(string $attributeName, string $className, string $message = "") { 170 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassHasAttribute', func_get_args())); 171 | } 172 | 173 | 174 | /** 175 | * [!] Method is generated. Documentation taken from corresponding module. 176 | * 177 | * Asserts that a class has a specified static attribute. 178 | * @see \Codeception\Module\AbstractAsserts::assertClassHasStaticAttribute() 179 | */ 180 | public function assertClassHasStaticAttribute(string $attributeName, string $className, string $message = "") { 181 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassHasStaticAttribute', func_get_args())); 182 | } 183 | 184 | 185 | /** 186 | * [!] Method is generated. Documentation taken from corresponding module. 187 | * 188 | * Asserts that a class does not have a specified attribute. 189 | * @see \Codeception\Module\AbstractAsserts::assertClassNotHasAttribute() 190 | */ 191 | public function assertClassNotHasAttribute(string $attributeName, string $className, string $message = "") { 192 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassNotHasAttribute', func_get_args())); 193 | } 194 | 195 | 196 | /** 197 | * [!] Method is generated. Documentation taken from corresponding module. 198 | * 199 | * Asserts that a class does not have a specified static attribute. 200 | * @see \Codeception\Module\AbstractAsserts::assertClassNotHasStaticAttribute() 201 | */ 202 | public function assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = "") { 203 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassNotHasStaticAttribute', func_get_args())); 204 | } 205 | 206 | 207 | /** 208 | * [!] Method is generated. Documentation taken from corresponding module. 209 | * 210 | * Asserts that a haystack contains a needle. 211 | * 212 | * @param mixed $needle 213 | * @see \Codeception\Module\AbstractAsserts::assertContains() 214 | */ 215 | public function assertContains($needle, iterable $haystack, string $message = "") { 216 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContains', func_get_args())); 217 | } 218 | 219 | 220 | /** 221 | * [!] Method is generated. Documentation taken from corresponding module. 222 | * 223 | * @param mixed $needle 224 | * @see \Codeception\Module\AbstractAsserts::assertContainsEquals() 225 | */ 226 | public function assertContainsEquals($needle, iterable $haystack, string $message = "") { 227 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContainsEquals', func_get_args())); 228 | } 229 | 230 | 231 | /** 232 | * [!] Method is generated. Documentation taken from corresponding module. 233 | * 234 | * Asserts that a haystack contains only values of a given type. 235 | * @see \Codeception\Module\AbstractAsserts::assertContainsOnly() 236 | */ 237 | public function assertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = NULL, string $message = "") { 238 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContainsOnly', func_get_args())); 239 | } 240 | 241 | 242 | /** 243 | * [!] Method is generated. Documentation taken from corresponding module. 244 | * 245 | * Asserts that a haystack contains only instances of a given class name. 246 | * @see \Codeception\Module\AbstractAsserts::assertContainsOnlyInstancesOf() 247 | */ 248 | public function assertContainsOnlyInstancesOf(string $className, iterable $haystack, string $message = "") { 249 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContainsOnlyInstancesOf', func_get_args())); 250 | } 251 | 252 | 253 | /** 254 | * [!] Method is generated. Documentation taken from corresponding module. 255 | * 256 | * Asserts the number of elements of an array, Countable or Traversable. 257 | * 258 | * @param \Countable|iterable $haystack 259 | * @see \Codeception\Module\AbstractAsserts::assertCount() 260 | */ 261 | public function assertCount(int $expectedCount, $haystack, string $message = "") { 262 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertCount', func_get_args())); 263 | } 264 | 265 | 266 | /** 267 | * [!] Method is generated. Documentation taken from corresponding module. 268 | * 269 | * Asserts that a directory does not exist. 270 | * @see \Codeception\Module\AbstractAsserts::assertDirectoryDoesNotExist() 271 | */ 272 | public function assertDirectoryDoesNotExist(string $directory, string $message = "") { 273 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryDoesNotExist', func_get_args())); 274 | } 275 | 276 | 277 | /** 278 | * [!] Method is generated. Documentation taken from corresponding module. 279 | * 280 | * Asserts that a directory exists. 281 | * @see \Codeception\Module\AbstractAsserts::assertDirectoryExists() 282 | */ 283 | public function assertDirectoryExists(string $directory, string $message = "") { 284 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryExists', func_get_args())); 285 | } 286 | 287 | 288 | /** 289 | * [!] Method is generated. Documentation taken from corresponding module. 290 | * 291 | * Asserts that a directory exists and is not readable. 292 | * @see \Codeception\Module\AbstractAsserts::assertDirectoryIsNotReadable() 293 | */ 294 | public function assertDirectoryIsNotReadable(string $directory, string $message = "") { 295 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsNotReadable', func_get_args())); 296 | } 297 | 298 | 299 | /** 300 | * [!] Method is generated. Documentation taken from corresponding module. 301 | * 302 | * Asserts that a directory exists and is not writable. 303 | * @see \Codeception\Module\AbstractAsserts::assertDirectoryIsNotWritable() 304 | */ 305 | public function assertDirectoryIsNotWritable(string $directory, string $message = "") { 306 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsNotWritable', func_get_args())); 307 | } 308 | 309 | 310 | /** 311 | * [!] Method is generated. Documentation taken from corresponding module. 312 | * 313 | * Asserts that a directory exists and is readable. 314 | * @see \Codeception\Module\AbstractAsserts::assertDirectoryIsReadable() 315 | */ 316 | public function assertDirectoryIsReadable(string $directory, string $message = "") { 317 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsReadable', func_get_args())); 318 | } 319 | 320 | 321 | /** 322 | * [!] Method is generated. Documentation taken from corresponding module. 323 | * 324 | * Asserts that a directory exists and is writable. 325 | * @see \Codeception\Module\AbstractAsserts::assertDirectoryIsWritable() 326 | */ 327 | public function assertDirectoryIsWritable(string $directory, string $message = "") { 328 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsWritable', func_get_args())); 329 | } 330 | 331 | 332 | /** 333 | * [!] Method is generated. Documentation taken from corresponding module. 334 | * 335 | * Asserts that a string does not match a given regular expression. 336 | * @see \Codeception\Module\AbstractAsserts::assertDoesNotMatchRegularExpression() 337 | */ 338 | public function assertDoesNotMatchRegularExpression(string $pattern, string $string, string $message = "") { 339 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDoesNotMatchRegularExpression', func_get_args())); 340 | } 341 | 342 | 343 | /** 344 | * [!] Method is generated. Documentation taken from corresponding module. 345 | * 346 | * Asserts that a variable is empty. 347 | * 348 | * @param mixed $actual 349 | * 350 | * @phpstan-assert empty $actual 351 | * @see \Codeception\Module\AbstractAsserts::assertEmpty() 352 | */ 353 | public function assertEmpty($actual, string $message = "") { 354 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args())); 355 | } 356 | 357 | 358 | /** 359 | * [!] Method is generated. Documentation taken from corresponding module. 360 | * 361 | * Asserts that two variables are equal. 362 | * 363 | * @param mixed $expected 364 | * @param mixed $actual 365 | * @see \Codeception\Module\AbstractAsserts::assertEquals() 366 | */ 367 | public function assertEquals($expected, $actual, string $message = "") { 368 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args())); 369 | } 370 | 371 | 372 | /** 373 | * [!] Method is generated. Documentation taken from corresponding module. 374 | * 375 | * Asserts that two variables are equal (canonicalizing). 376 | * 377 | * @param mixed $expected 378 | * @param mixed $actual 379 | * @see \Codeception\Module\AbstractAsserts::assertEqualsCanonicalizing() 380 | */ 381 | public function assertEqualsCanonicalizing($expected, $actual, string $message = "") { 382 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEqualsCanonicalizing', func_get_args())); 383 | } 384 | 385 | 386 | /** 387 | * [!] Method is generated. Documentation taken from corresponding module. 388 | * 389 | * Asserts that two variables are equal (ignoring case). 390 | * 391 | * @param mixed $expected 392 | * @param mixed $actual 393 | * @see \Codeception\Module\AbstractAsserts::assertEqualsIgnoringCase() 394 | */ 395 | public function assertEqualsIgnoringCase($expected, $actual, string $message = "") { 396 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEqualsIgnoringCase', func_get_args())); 397 | } 398 | 399 | 400 | /** 401 | * [!] Method is generated. Documentation taken from corresponding module. 402 | * 403 | * Asserts that two variables are equal (with delta). 404 | * 405 | * @param mixed $expected 406 | * @param mixed $actual 407 | * @see \Codeception\Module\AbstractAsserts::assertEqualsWithDelta() 408 | */ 409 | public function assertEqualsWithDelta($expected, $actual, float $delta, string $message = "") { 410 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEqualsWithDelta', func_get_args())); 411 | } 412 | 413 | 414 | /** 415 | * [!] Method is generated. Documentation taken from corresponding module. 416 | * 417 | * Asserts that a condition is false. 418 | * 419 | * @param mixed $condition 420 | * 421 | * @phpstan-assert false $condition 422 | * @see \Codeception\Module\AbstractAsserts::assertFalse() 423 | */ 424 | public function assertFalse($condition, string $message = "") { 425 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFalse', func_get_args())); 426 | } 427 | 428 | 429 | /** 430 | * [!] Method is generated. Documentation taken from corresponding module. 431 | * 432 | * Asserts that a file does not exist. 433 | * @see \Codeception\Module\AbstractAsserts::assertFileDoesNotExist() 434 | */ 435 | public function assertFileDoesNotExist(string $filename, string $message = "") { 436 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileDoesNotExist', func_get_args())); 437 | } 438 | 439 | 440 | /** 441 | * [!] Method is generated. Documentation taken from corresponding module. 442 | * 443 | * Asserts that the contents of one file is equal to the contents of another file. 444 | * @see \Codeception\Module\AbstractAsserts::assertFileEquals() 445 | */ 446 | public function assertFileEquals(string $expected, string $actual, string $message = "") { 447 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileEquals', func_get_args())); 448 | } 449 | 450 | 451 | /** 452 | * [!] Method is generated. Documentation taken from corresponding module. 453 | * 454 | * Asserts that the contents of one file is equal to the contents of another file (canonicalizing). 455 | * @see \Codeception\Module\AbstractAsserts::assertFileEqualsCanonicalizing() 456 | */ 457 | public function assertFileEqualsCanonicalizing(string $expected, string $actual, string $message = "") { 458 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileEqualsCanonicalizing', func_get_args())); 459 | } 460 | 461 | 462 | /** 463 | * [!] Method is generated. Documentation taken from corresponding module. 464 | * 465 | * Asserts that the contents of one file is equal to the contents of another file (ignoring case). 466 | * @see \Codeception\Module\AbstractAsserts::assertFileEqualsIgnoringCase() 467 | */ 468 | public function assertFileEqualsIgnoringCase(string $expected, string $actual, string $message = "") { 469 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileEqualsIgnoringCase', func_get_args())); 470 | } 471 | 472 | 473 | /** 474 | * [!] Method is generated. Documentation taken from corresponding module. 475 | * 476 | * Asserts that a file exists. 477 | * @see \Codeception\Module\AbstractAsserts::assertFileExists() 478 | */ 479 | public function assertFileExists(string $filename, string $message = "") { 480 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileExists', func_get_args())); 481 | } 482 | 483 | 484 | /** 485 | * [!] Method is generated. Documentation taken from corresponding module. 486 | * 487 | * Asserts that a file exists and is not readable. 488 | * @see \Codeception\Module\AbstractAsserts::assertFileIsNotReadable() 489 | */ 490 | public function assertFileIsNotReadable(string $file, string $message = "") { 491 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsNotReadable', func_get_args())); 492 | } 493 | 494 | 495 | /** 496 | * [!] Method is generated. Documentation taken from corresponding module. 497 | * 498 | * Asserts that a file exists and is not writable. 499 | * @see \Codeception\Module\AbstractAsserts::assertFileIsNotWritable() 500 | */ 501 | public function assertFileIsNotWritable(string $file, string $message = "") { 502 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsNotWritable', func_get_args())); 503 | } 504 | 505 | 506 | /** 507 | * [!] Method is generated. Documentation taken from corresponding module. 508 | * 509 | * Asserts that a file exists and is readable. 510 | * @see \Codeception\Module\AbstractAsserts::assertFileIsReadable() 511 | */ 512 | public function assertFileIsReadable(string $file, string $message = "") { 513 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsReadable', func_get_args())); 514 | } 515 | 516 | 517 | /** 518 | * [!] Method is generated. Documentation taken from corresponding module. 519 | * 520 | * Asserts that a file exists and is writable. 521 | * @see \Codeception\Module\AbstractAsserts::assertFileIsWritable() 522 | */ 523 | public function assertFileIsWritable(string $file, string $message = "") { 524 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsWritable', func_get_args())); 525 | } 526 | 527 | 528 | /** 529 | * [!] Method is generated. Documentation taken from corresponding module. 530 | * 531 | * Asserts that the contents of one file is not equal to the contents of another file. 532 | * @see \Codeception\Module\AbstractAsserts::assertFileNotEquals() 533 | */ 534 | public function assertFileNotEquals(string $expected, string $actual, string $message = "") { 535 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotEquals', func_get_args())); 536 | } 537 | 538 | 539 | /** 540 | * [!] Method is generated. Documentation taken from corresponding module. 541 | * 542 | * Asserts that the contents of one file is not equal to the contents of another file (canonicalizing). 543 | * @see \Codeception\Module\AbstractAsserts::assertFileNotEqualsCanonicalizing() 544 | */ 545 | public function assertFileNotEqualsCanonicalizing(string $expected, string $actual, string $message = "") { 546 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotEqualsCanonicalizing', func_get_args())); 547 | } 548 | 549 | 550 | /** 551 | * [!] Method is generated. Documentation taken from corresponding module. 552 | * 553 | * Asserts that the contents of one file is not equal to the contents of another file (ignoring case). 554 | * @see \Codeception\Module\AbstractAsserts::assertFileNotEqualsIgnoringCase() 555 | */ 556 | public function assertFileNotEqualsIgnoringCase(string $expected, string $actual, string $message = "") { 557 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotEqualsIgnoringCase', func_get_args())); 558 | } 559 | 560 | 561 | /** 562 | * [!] Method is generated. Documentation taken from corresponding module. 563 | * 564 | * Asserts that a variable is finite. 565 | * 566 | * @param mixed $actual 567 | * @see \Codeception\Module\AbstractAsserts::assertFinite() 568 | */ 569 | public function assertFinite($actual, string $message = "") { 570 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFinite', func_get_args())); 571 | } 572 | 573 | 574 | /** 575 | * [!] Method is generated. Documentation taken from corresponding module. 576 | * 577 | * Asserts that a value is greater than another value. 578 | * 579 | * @param mixed $expected 580 | * @param mixed $actual 581 | * @see \Codeception\Module\AbstractAsserts::assertGreaterThan() 582 | */ 583 | public function assertGreaterThan($expected, $actual, string $message = "") { 584 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThan', func_get_args())); 585 | } 586 | 587 | 588 | /** 589 | * [!] Method is generated. Documentation taken from corresponding module. 590 | * 591 | * Asserts that a value is greater than or equal to another value. 592 | * 593 | * @param mixed $expected 594 | * @param mixed $actual 595 | * @see \Codeception\Module\AbstractAsserts::assertGreaterThanOrEqual() 596 | */ 597 | public function assertGreaterThanOrEqual($expected, $actual, string $message = "") { 598 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThanOrEqual', func_get_args())); 599 | } 600 | 601 | 602 | /** 603 | * [!] Method is generated. Documentation taken from corresponding module. 604 | * 605 | * Asserts that a variable is infinite. 606 | * 607 | * @param mixed $actual 608 | * @see \Codeception\Module\AbstractAsserts::assertInfinite() 609 | */ 610 | public function assertInfinite($actual, string $message = "") { 611 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInfinite', func_get_args())); 612 | } 613 | 614 | 615 | /** 616 | * [!] Method is generated. Documentation taken from corresponding module. 617 | * 618 | * Asserts that a variable is of a given type. 619 | * 620 | * @template ExpectedType of object 621 | * 622 | * @param mixed $actual 623 | * @param class-string $expected 624 | * 625 | * @phpstan-assert =ExpectedType $actual 626 | * @see \Codeception\Module\AbstractAsserts::assertInstanceOf() 627 | */ 628 | public function assertInstanceOf(string $expected, $actual, string $message = "") { 629 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInstanceOf', func_get_args())); 630 | } 631 | 632 | 633 | /** 634 | * [!] Method is generated. Documentation taken from corresponding module. 635 | * 636 | * Asserts that a variable is of type array. 637 | * 638 | * @param mixed $actual 639 | * 640 | * @phpstan-assert array $actual 641 | * @see \Codeception\Module\AbstractAsserts::assertIsArray() 642 | */ 643 | public function assertIsArray($actual, string $message = "") { 644 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsArray', func_get_args())); 645 | } 646 | 647 | 648 | /** 649 | * [!] Method is generated. Documentation taken from corresponding module. 650 | * 651 | * Asserts that a variable is of type bool. 652 | * 653 | * @param mixed $actual 654 | * 655 | * @phpstan-assert bool $actual 656 | * @see \Codeception\Module\AbstractAsserts::assertIsBool() 657 | */ 658 | public function assertIsBool($actual, string $message = "") { 659 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsBool', func_get_args())); 660 | } 661 | 662 | 663 | /** 664 | * [!] Method is generated. Documentation taken from corresponding module. 665 | * 666 | * Asserts that a variable is of type callable. 667 | * 668 | * @param mixed $actual 669 | * 670 | * @phpstan-assert callable $actual 671 | * @see \Codeception\Module\AbstractAsserts::assertIsCallable() 672 | */ 673 | public function assertIsCallable($actual, string $message = "") { 674 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsCallable', func_get_args())); 675 | } 676 | 677 | 678 | /** 679 | * [!] Method is generated. Documentation taken from corresponding module. 680 | * 681 | * Asserts that a variable is of type resource and is closed. 682 | * 683 | * @param mixed $actual 684 | * 685 | * @phpstan-assert resource $actual 686 | * @see \Codeception\Module\AbstractAsserts::assertIsClosedResource() 687 | */ 688 | public function assertIsClosedResource($actual, string $message = "") { 689 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsClosedResource', func_get_args())); 690 | } 691 | 692 | 693 | /** 694 | * [!] Method is generated. Documentation taken from corresponding module. 695 | * 696 | * Asserts that a variable is of type float. 697 | * 698 | * @param mixed $actual 699 | * 700 | * @phpstan-assert float $actual 701 | * @see \Codeception\Module\AbstractAsserts::assertIsFloat() 702 | */ 703 | public function assertIsFloat($actual, string $message = "") { 704 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsFloat', func_get_args())); 705 | } 706 | 707 | 708 | /** 709 | * [!] Method is generated. Documentation taken from corresponding module. 710 | * 711 | * Asserts that a variable is of type int. 712 | * 713 | * @param mixed $actual 714 | * 715 | * @phpstan-assert int $actual 716 | * @see \Codeception\Module\AbstractAsserts::assertIsInt() 717 | */ 718 | public function assertIsInt($actual, string $message = "") { 719 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsInt', func_get_args())); 720 | } 721 | 722 | 723 | /** 724 | * [!] Method is generated. Documentation taken from corresponding module. 725 | * 726 | * Asserts that a variable is of type iterable. 727 | * 728 | * @param mixed $actual 729 | * 730 | * @phpstan-assert iterable $actual 731 | * @see \Codeception\Module\AbstractAsserts::assertIsIterable() 732 | */ 733 | public function assertIsIterable($actual, string $message = "") { 734 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsIterable', func_get_args())); 735 | } 736 | 737 | 738 | /** 739 | * [!] Method is generated. Documentation taken from corresponding module. 740 | * 741 | * Asserts that a variable is not of type array. 742 | * 743 | * @param mixed $actual 744 | * 745 | * @phpstan-assert !array $actual 746 | * @see \Codeception\Module\AbstractAsserts::assertIsNotArray() 747 | */ 748 | public function assertIsNotArray($actual, string $message = "") { 749 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotArray', func_get_args())); 750 | } 751 | 752 | 753 | /** 754 | * [!] Method is generated. Documentation taken from corresponding module. 755 | * 756 | * Asserts that a variable is not of type bool. 757 | * 758 | * @param mixed $actual 759 | * 760 | * @phpstan-assert !bool $actual 761 | * @see \Codeception\Module\AbstractAsserts::assertIsNotBool() 762 | */ 763 | public function assertIsNotBool($actual, string $message = "") { 764 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotBool', func_get_args())); 765 | } 766 | 767 | 768 | /** 769 | * [!] Method is generated. Documentation taken from corresponding module. 770 | * 771 | * Asserts that a variable is not of type callable. 772 | * 773 | * @param mixed $actual 774 | * 775 | * @phpstan-assert !callable $actual 776 | * @see \Codeception\Module\AbstractAsserts::assertIsNotCallable() 777 | */ 778 | public function assertIsNotCallable($actual, string $message = "") { 779 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotCallable', func_get_args())); 780 | } 781 | 782 | 783 | /** 784 | * [!] Method is generated. Documentation taken from corresponding module. 785 | * 786 | * Asserts that a variable is not of type resource. 787 | * 788 | * @param mixed $actual 789 | * 790 | * @phpstan-assert !resource $actual 791 | * @see \Codeception\Module\AbstractAsserts::assertIsNotClosedResource() 792 | */ 793 | public function assertIsNotClosedResource($actual, string $message = "") { 794 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotClosedResource', func_get_args())); 795 | } 796 | 797 | 798 | /** 799 | * [!] Method is generated. Documentation taken from corresponding module. 800 | * 801 | * Asserts that a variable is not of type float. 802 | * 803 | * @param mixed $actual 804 | * 805 | * @phpstan-assert !float $actual 806 | * @see \Codeception\Module\AbstractAsserts::assertIsNotFloat() 807 | */ 808 | public function assertIsNotFloat($actual, string $message = "") { 809 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotFloat', func_get_args())); 810 | } 811 | 812 | 813 | /** 814 | * [!] Method is generated. Documentation taken from corresponding module. 815 | * 816 | * Asserts that a variable is not of type int. 817 | * 818 | * @param mixed $actual 819 | * 820 | * @phpstan-assert !int $actual 821 | * @see \Codeception\Module\AbstractAsserts::assertIsNotInt() 822 | */ 823 | public function assertIsNotInt($actual, string $message = "") { 824 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotInt', func_get_args())); 825 | } 826 | 827 | 828 | /** 829 | * [!] Method is generated. Documentation taken from corresponding module. 830 | * 831 | * Asserts that a variable is not of type iterable. 832 | * 833 | * @param mixed $actual 834 | * 835 | * @phpstan-assert !iterable $actual 836 | * @see \Codeception\Module\AbstractAsserts::assertIsNotIterable() 837 | */ 838 | public function assertIsNotIterable($actual, string $message = "") { 839 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotIterable', func_get_args())); 840 | } 841 | 842 | 843 | /** 844 | * [!] Method is generated. Documentation taken from corresponding module. 845 | * 846 | * Asserts that a variable is not of type numeric. 847 | * 848 | * @param mixed $actual 849 | * 850 | * @phpstan-assert !numeric $actual 851 | * @see \Codeception\Module\AbstractAsserts::assertIsNotNumeric() 852 | */ 853 | public function assertIsNotNumeric($actual, string $message = "") { 854 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotNumeric', func_get_args())); 855 | } 856 | 857 | 858 | /** 859 | * [!] Method is generated. Documentation taken from corresponding module. 860 | * 861 | * Asserts that a variable is not of type object. 862 | * 863 | * @param mixed $actual 864 | * 865 | * @phpstan-assert !object $actual 866 | * @see \Codeception\Module\AbstractAsserts::assertIsNotObject() 867 | */ 868 | public function assertIsNotObject($actual, string $message = "") { 869 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotObject', func_get_args())); 870 | } 871 | 872 | 873 | /** 874 | * [!] Method is generated. Documentation taken from corresponding module. 875 | * 876 | * Asserts that a file/dir exists and is not readable. 877 | * @see \Codeception\Module\AbstractAsserts::assertIsNotReadable() 878 | */ 879 | public function assertIsNotReadable(string $filename, string $message = "") { 880 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotReadable', func_get_args())); 881 | } 882 | 883 | 884 | /** 885 | * [!] Method is generated. Documentation taken from corresponding module. 886 | * 887 | * Asserts that a variable is not of type resource. 888 | * 889 | * @param mixed $actual 890 | * 891 | * @phpstan-assert !resource $actual 892 | * @see \Codeception\Module\AbstractAsserts::assertIsNotResource() 893 | */ 894 | public function assertIsNotResource($actual, string $message = "") { 895 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotResource', func_get_args())); 896 | } 897 | 898 | 899 | /** 900 | * [!] Method is generated. Documentation taken from corresponding module. 901 | * 902 | * Asserts that a variable is not of type scalar. 903 | * 904 | * @param mixed $actual 905 | * 906 | * @psalm-assert !scalar $actual 907 | * @see \Codeception\Module\AbstractAsserts::assertIsNotScalar() 908 | */ 909 | public function assertIsNotScalar($actual, string $message = "") { 910 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotScalar', func_get_args())); 911 | } 912 | 913 | 914 | /** 915 | * [!] Method is generated. Documentation taken from corresponding module. 916 | * 917 | * Asserts that a variable is not of type string. 918 | * 919 | * @param mixed $actual 920 | * 921 | * @phpstan-assert !string $actual 922 | * @see \Codeception\Module\AbstractAsserts::assertIsNotString() 923 | */ 924 | public function assertIsNotString($actual, string $message = "") { 925 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotString', func_get_args())); 926 | } 927 | 928 | 929 | /** 930 | * [!] Method is generated. Documentation taken from corresponding module. 931 | * 932 | * Asserts that a file/dir exists and is not writable. 933 | * @see \Codeception\Module\AbstractAsserts::assertIsNotWritable() 934 | */ 935 | public function assertIsNotWritable(string $filename, string $message = "") { 936 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotWritable', func_get_args())); 937 | } 938 | 939 | 940 | /** 941 | * [!] Method is generated. Documentation taken from corresponding module. 942 | * 943 | * Asserts that a variable is of type numeric. 944 | * 945 | * @param mixed $actual 946 | * 947 | * @phpstan-assert numeric $actual 948 | * @see \Codeception\Module\AbstractAsserts::assertIsNumeric() 949 | */ 950 | public function assertIsNumeric($actual, string $message = "") { 951 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNumeric', func_get_args())); 952 | } 953 | 954 | 955 | /** 956 | * [!] Method is generated. Documentation taken from corresponding module. 957 | * 958 | * Asserts that a variable is of type object. 959 | * 960 | * @param mixed $actual 961 | * 962 | * @phpstan-assert object $actual 963 | * @see \Codeception\Module\AbstractAsserts::assertIsObject() 964 | */ 965 | public function assertIsObject($actual, string $message = "") { 966 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsObject', func_get_args())); 967 | } 968 | 969 | 970 | /** 971 | * [!] Method is generated. Documentation taken from corresponding module. 972 | * 973 | * Asserts that a file/dir is readable. 974 | * @see \Codeception\Module\AbstractAsserts::assertIsReadable() 975 | */ 976 | public function assertIsReadable(string $filename, string $message = "") { 977 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsReadable', func_get_args())); 978 | } 979 | 980 | 981 | /** 982 | * [!] Method is generated. Documentation taken from corresponding module. 983 | * 984 | * Asserts that a variable is of type resource. 985 | * 986 | * @param mixed $actual 987 | * 988 | * @phpstan-assert resource $actual 989 | * @see \Codeception\Module\AbstractAsserts::assertIsResource() 990 | */ 991 | public function assertIsResource($actual, string $message = "") { 992 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsResource', func_get_args())); 993 | } 994 | 995 | 996 | /** 997 | * [!] Method is generated. Documentation taken from corresponding module. 998 | * 999 | * Asserts that a variable is of type scalar. 1000 | * 1001 | * @param mixed $actual 1002 | * 1003 | * @phpstan-assert scalar $actual 1004 | * @see \Codeception\Module\AbstractAsserts::assertIsScalar() 1005 | */ 1006 | public function assertIsScalar($actual, string $message = "") { 1007 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsScalar', func_get_args())); 1008 | } 1009 | 1010 | 1011 | /** 1012 | * [!] Method is generated. Documentation taken from corresponding module. 1013 | * 1014 | * Asserts that a variable is of type string. 1015 | * 1016 | * @param mixed $actual 1017 | * 1018 | * @phpstan-assert string $actual 1019 | * @see \Codeception\Module\AbstractAsserts::assertIsString() 1020 | */ 1021 | public function assertIsString($actual, string $message = "") { 1022 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsString', func_get_args())); 1023 | } 1024 | 1025 | 1026 | /** 1027 | * [!] Method is generated. Documentation taken from corresponding module. 1028 | * 1029 | * Asserts that a file/dir exists and is writable. 1030 | * @see \Codeception\Module\AbstractAsserts::assertIsWritable() 1031 | */ 1032 | public function assertIsWritable(string $filename, string $message = "") { 1033 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsWritable', func_get_args())); 1034 | } 1035 | 1036 | 1037 | /** 1038 | * [!] Method is generated. Documentation taken from corresponding module. 1039 | * 1040 | * Asserts that a string is a valid JSON string. 1041 | * @see \Codeception\Module\AbstractAsserts::assertJson() 1042 | */ 1043 | public function assertJson(string $actualJson, string $message = "") { 1044 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJson', func_get_args())); 1045 | } 1046 | 1047 | 1048 | /** 1049 | * [!] Method is generated. Documentation taken from corresponding module. 1050 | * 1051 | * Asserts that two JSON files are equal. 1052 | * @see \Codeception\Module\AbstractAsserts::assertJsonFileEqualsJsonFile() 1053 | */ 1054 | public function assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = "") { 1055 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonFileEqualsJsonFile', func_get_args())); 1056 | } 1057 | 1058 | 1059 | /** 1060 | * [!] Method is generated. Documentation taken from corresponding module. 1061 | * 1062 | * Asserts that two JSON files are not equal. 1063 | * @see \Codeception\Module\AbstractAsserts::assertJsonFileNotEqualsJsonFile() 1064 | */ 1065 | public function assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = "") { 1066 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonFileNotEqualsJsonFile', func_get_args())); 1067 | } 1068 | 1069 | 1070 | /** 1071 | * [!] Method is generated. Documentation taken from corresponding module. 1072 | * 1073 | * Asserts that the generated JSON encoded object and the content of the given file are equal. 1074 | * @see \Codeception\Module\AbstractAsserts::assertJsonStringEqualsJsonFile() 1075 | */ 1076 | public function assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = "") { 1077 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonStringEqualsJsonFile', func_get_args())); 1078 | } 1079 | 1080 | 1081 | /** 1082 | * [!] Method is generated. Documentation taken from corresponding module. 1083 | * 1084 | * Asserts that two given JSON encoded objects or arrays are equal. 1085 | * @see \Codeception\Module\AbstractAsserts::assertJsonStringEqualsJsonString() 1086 | */ 1087 | public function assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = "") { 1088 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonStringEqualsJsonString', func_get_args())); 1089 | } 1090 | 1091 | 1092 | /** 1093 | * [!] Method is generated. Documentation taken from corresponding module. 1094 | * 1095 | * Asserts that the generated JSON encoded object and the content of the given file are not equal. 1096 | * @see \Codeception\Module\AbstractAsserts::assertJsonStringNotEqualsJsonFile() 1097 | */ 1098 | public function assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = "") { 1099 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonStringNotEqualsJsonFile', func_get_args())); 1100 | } 1101 | 1102 | 1103 | /** 1104 | * [!] Method is generated. Documentation taken from corresponding module. 1105 | * 1106 | * Asserts that two given JSON encoded objects or arrays are not equal. 1107 | * @see \Codeception\Module\AbstractAsserts::assertJsonStringNotEqualsJsonString() 1108 | */ 1109 | public function assertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson, string $message = "") { 1110 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonStringNotEqualsJsonString', func_get_args())); 1111 | } 1112 | 1113 | 1114 | /** 1115 | * [!] Method is generated. Documentation taken from corresponding module. 1116 | * 1117 | * Asserts that a value is smaller than another value. 1118 | * 1119 | * @param mixed $expected 1120 | * @param mixed $actual 1121 | * @see \Codeception\Module\AbstractAsserts::assertLessThan() 1122 | */ 1123 | public function assertLessThan($expected, $actual, string $message = "") { 1124 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThan', func_get_args())); 1125 | } 1126 | 1127 | 1128 | /** 1129 | * [!] Method is generated. Documentation taken from corresponding module. 1130 | * 1131 | * Asserts that a value is smaller than or equal to another value. 1132 | * 1133 | * @param mixed $expected 1134 | * @param mixed $actual 1135 | * @see \Codeception\Module\AbstractAsserts::assertLessThanOrEqual() 1136 | */ 1137 | public function assertLessThanOrEqual($expected, $actual, string $message = "") { 1138 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThanOrEqual', func_get_args())); 1139 | } 1140 | 1141 | 1142 | /** 1143 | * [!] Method is generated. Documentation taken from corresponding module. 1144 | * 1145 | * Asserts that a string matches a given regular expression. 1146 | * @see \Codeception\Module\AbstractAsserts::assertMatchesRegularExpression() 1147 | */ 1148 | public function assertMatchesRegularExpression(string $pattern, string $string, string $message = "") { 1149 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertMatchesRegularExpression', func_get_args())); 1150 | } 1151 | 1152 | 1153 | /** 1154 | * [!] Method is generated. Documentation taken from corresponding module. 1155 | * 1156 | * Asserts that a variable is nan. 1157 | * 1158 | * @param mixed $actual 1159 | * @see \Codeception\Module\AbstractAsserts::assertNan() 1160 | */ 1161 | public function assertNan($actual, string $message = "") { 1162 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNan', func_get_args())); 1163 | } 1164 | 1165 | 1166 | /** 1167 | * [!] Method is generated. Documentation taken from corresponding module. 1168 | * 1169 | * Asserts that a haystack does not contain a needle. 1170 | * 1171 | * @param mixed $needle 1172 | * @see \Codeception\Module\AbstractAsserts::assertNotContains() 1173 | */ 1174 | public function assertNotContains($needle, iterable $haystack, string $message = "") { 1175 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContains', func_get_args())); 1176 | } 1177 | 1178 | 1179 | /** 1180 | * [!] Method is generated. Documentation taken from corresponding module. 1181 | * 1182 | * 1183 | * @see \Codeception\Module\AbstractAsserts::assertNotContainsEquals() 1184 | */ 1185 | public function assertNotContainsEquals($needle, iterable $haystack, string $message = "") { 1186 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContainsEquals', func_get_args())); 1187 | } 1188 | 1189 | 1190 | /** 1191 | * [!] Method is generated. Documentation taken from corresponding module. 1192 | * 1193 | * Asserts that a haystack does not contain only values of a given type. 1194 | * @see \Codeception\Module\AbstractAsserts::assertNotContainsOnly() 1195 | */ 1196 | public function assertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = NULL, string $message = "") { 1197 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContainsOnly', func_get_args())); 1198 | } 1199 | 1200 | 1201 | /** 1202 | * [!] Method is generated. Documentation taken from corresponding module. 1203 | * 1204 | * Asserts the number of elements of an array, Countable or Traversable. 1205 | * 1206 | * @param \Countable|iterable $haystack 1207 | * @see \Codeception\Module\AbstractAsserts::assertNotCount() 1208 | */ 1209 | public function assertNotCount(int $expectedCount, $haystack, string $message = "") { 1210 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotCount', func_get_args())); 1211 | } 1212 | 1213 | 1214 | /** 1215 | * [!] Method is generated. Documentation taken from corresponding module. 1216 | * 1217 | * Asserts that a variable is not empty. 1218 | * 1219 | * @param mixed $actual 1220 | * 1221 | * @phpstan-assert !empty $actual 1222 | * @see \Codeception\Module\AbstractAsserts::assertNotEmpty() 1223 | */ 1224 | public function assertNotEmpty($actual, string $message = "") { 1225 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEmpty', func_get_args())); 1226 | } 1227 | 1228 | 1229 | /** 1230 | * [!] Method is generated. Documentation taken from corresponding module. 1231 | * 1232 | * Asserts that two variables are not equal. 1233 | * 1234 | * @param mixed $expected 1235 | * @param mixed $actual 1236 | * @see \Codeception\Module\AbstractAsserts::assertNotEquals() 1237 | */ 1238 | public function assertNotEquals($expected, $actual, string $message = "") { 1239 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args())); 1240 | } 1241 | 1242 | 1243 | /** 1244 | * [!] Method is generated. Documentation taken from corresponding module. 1245 | * 1246 | * Asserts that two variables are not equal (canonicalizing). 1247 | * 1248 | * @param mixed $expected 1249 | * @param mixed $actual 1250 | * @see \Codeception\Module\AbstractAsserts::assertNotEqualsCanonicalizing() 1251 | */ 1252 | public function assertNotEqualsCanonicalizing($expected, $actual, string $message = "") { 1253 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEqualsCanonicalizing', func_get_args())); 1254 | } 1255 | 1256 | 1257 | /** 1258 | * [!] Method is generated. Documentation taken from corresponding module. 1259 | * 1260 | * Asserts that two variables are not equal (ignoring case). 1261 | * 1262 | * @param mixed $expected 1263 | * @param mixed $actual 1264 | * @see \Codeception\Module\AbstractAsserts::assertNotEqualsIgnoringCase() 1265 | */ 1266 | public function assertNotEqualsIgnoringCase($expected, $actual, string $message = "") { 1267 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEqualsIgnoringCase', func_get_args())); 1268 | } 1269 | 1270 | 1271 | /** 1272 | * [!] Method is generated. Documentation taken from corresponding module. 1273 | * 1274 | * Asserts that two variables are not equal (with delta). 1275 | * 1276 | * @param mixed $expected 1277 | * @param mixed $actual 1278 | * @see \Codeception\Module\AbstractAsserts::assertNotEqualsWithDelta() 1279 | */ 1280 | public function assertNotEqualsWithDelta($expected, $actual, float $delta, string $message = "") { 1281 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEqualsWithDelta', func_get_args())); 1282 | } 1283 | 1284 | 1285 | /** 1286 | * [!] Method is generated. Documentation taken from corresponding module. 1287 | * 1288 | * Asserts that a condition is not false. 1289 | * 1290 | * @param mixed $condition 1291 | * 1292 | * @phpstan-assert !false $condition 1293 | * @see \Codeception\Module\AbstractAsserts::assertNotFalse() 1294 | */ 1295 | public function assertNotFalse($condition, string $message = "") { 1296 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotFalse', func_get_args())); 1297 | } 1298 | 1299 | 1300 | /** 1301 | * [!] Method is generated. Documentation taken from corresponding module. 1302 | * 1303 | * Asserts that a variable is not of a given type. 1304 | * 1305 | * @template ExpectedType of object 1306 | * 1307 | * @param mixed $actual 1308 | * @param class-string $expected 1309 | * 1310 | * @phpstan-assert !ExpectedType $actual 1311 | * @see \Codeception\Module\AbstractAsserts::assertNotInstanceOf() 1312 | */ 1313 | public function assertNotInstanceOf(string $expected, $actual, string $message = "") { 1314 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotInstanceOf', func_get_args())); 1315 | } 1316 | 1317 | 1318 | /** 1319 | * [!] Method is generated. Documentation taken from corresponding module. 1320 | * 1321 | * Asserts that a variable is not null. 1322 | * 1323 | * @param mixed $actual 1324 | * 1325 | * @phpstan-assert !null $actual 1326 | * @see \Codeception\Module\AbstractAsserts::assertNotNull() 1327 | */ 1328 | public function assertNotNull($actual, string $message = "") { 1329 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotNull', func_get_args())); 1330 | } 1331 | 1332 | 1333 | /** 1334 | * [!] Method is generated. Documentation taken from corresponding module. 1335 | * 1336 | * Asserts that two variables do not have the same type and value. 1337 | * 1338 | * @param mixed $expected 1339 | * @param mixed $actual 1340 | * @see \Codeception\Module\AbstractAsserts::assertNotSame() 1341 | */ 1342 | public function assertNotSame($expected, $actual, string $message = "") { 1343 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotSame', func_get_args())); 1344 | } 1345 | 1346 | 1347 | /** 1348 | * [!] Method is generated. Documentation taken from corresponding module. 1349 | * 1350 | * Assert that the size of two arrays (or `Countable` or `Traversable` objects) is not the same. 1351 | * 1352 | * @param \Countable|iterable $expected 1353 | * @param \Countable|iterable $actual 1354 | * @see \Codeception\Module\AbstractAsserts::assertNotSameSize() 1355 | */ 1356 | public function assertNotSameSize($expected, $actual, string $message = "") { 1357 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotSameSize', func_get_args())); 1358 | } 1359 | 1360 | 1361 | /** 1362 | * [!] Method is generated. Documentation taken from corresponding module. 1363 | * 1364 | * Asserts that a condition is not true. 1365 | * 1366 | * @param mixed $condition 1367 | * 1368 | * @phpstan-assert !true $condition 1369 | * @see \Codeception\Module\AbstractAsserts::assertNotTrue() 1370 | */ 1371 | public function assertNotTrue($condition, string $message = "") { 1372 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotTrue', func_get_args())); 1373 | } 1374 | 1375 | 1376 | /** 1377 | * [!] Method is generated. Documentation taken from corresponding module. 1378 | * 1379 | * Asserts that a variable is null. 1380 | * 1381 | * @param mixed $actual 1382 | * 1383 | * @phpstan-assert null $actual 1384 | * @see \Codeception\Module\AbstractAsserts::assertNull() 1385 | */ 1386 | public function assertNull($actual, string $message = "") { 1387 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNull', func_get_args())); 1388 | } 1389 | 1390 | 1391 | /** 1392 | * [!] Method is generated. Documentation taken from corresponding module. 1393 | * 1394 | * Asserts that an object has a specified attribute. 1395 | * @see \Codeception\Module\AbstractAsserts::assertObjectHasAttribute() 1396 | */ 1397 | public function assertObjectHasAttribute(string $attributeName, object $object, string $message = "") { 1398 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertObjectHasAttribute', func_get_args())); 1399 | } 1400 | 1401 | 1402 | /** 1403 | * [!] Method is generated. Documentation taken from corresponding module. 1404 | * 1405 | * Asserts that an object does not have a specified attribute. 1406 | * @see \Codeception\Module\AbstractAsserts::assertObjectNotHasAttribute() 1407 | */ 1408 | public function assertObjectNotHasAttribute(string $attributeName, object $object, string $message = "") { 1409 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertObjectNotHasAttribute', func_get_args())); 1410 | } 1411 | 1412 | 1413 | /** 1414 | * [!] Method is generated. Documentation taken from corresponding module. 1415 | * 1416 | * Asserts that two variables have the same type and value. 1417 | * Used on objects, it asserts that two variables reference 1418 | * the same object. 1419 | * 1420 | * @template ExpectedType 1421 | * 1422 | * @param ExpectedType $expected 1423 | * @param mixed $actual 1424 | * 1425 | * @phpstan-assert =ExpectedType $actual 1426 | * @see \Codeception\Module\AbstractAsserts::assertSame() 1427 | */ 1428 | public function assertSame($expected, $actual, string $message = "") { 1429 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertSame', func_get_args())); 1430 | } 1431 | 1432 | 1433 | /** 1434 | * [!] Method is generated. Documentation taken from corresponding module. 1435 | * 1436 | * Assert that the size of two arrays (or `Countable` or `Traversable` objects) is the same. 1437 | * 1438 | * @param \Countable|iterable $expected 1439 | * @param \Countable|iterable $actual 1440 | * @see \Codeception\Module\AbstractAsserts::assertSameSize() 1441 | */ 1442 | public function assertSameSize($expected, $actual, string $message = "") { 1443 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertSameSize', func_get_args())); 1444 | } 1445 | 1446 | 1447 | /** 1448 | * [!] Method is generated. Documentation taken from corresponding module. 1449 | * 1450 | * 1451 | * @see \Codeception\Module\AbstractAsserts::assertStringContainsString() 1452 | */ 1453 | public function assertStringContainsString(string $needle, string $haystack, string $message = "") { 1454 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringContainsString', func_get_args())); 1455 | } 1456 | 1457 | 1458 | /** 1459 | * [!] Method is generated. Documentation taken from corresponding module. 1460 | * 1461 | * 1462 | * @see \Codeception\Module\AbstractAsserts::assertStringContainsStringIgnoringCase() 1463 | */ 1464 | public function assertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = "") { 1465 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringContainsStringIgnoringCase', func_get_args())); 1466 | } 1467 | 1468 | 1469 | /** 1470 | * [!] Method is generated. Documentation taken from corresponding module. 1471 | * 1472 | * Asserts that a string ends not with a given suffix. 1473 | * @see \Codeception\Module\AbstractAsserts::assertStringEndsNotWith() 1474 | */ 1475 | public function assertStringEndsNotWith(string $suffix, string $string, string $message = "") { 1476 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEndsNotWith', func_get_args())); 1477 | } 1478 | 1479 | 1480 | /** 1481 | * [!] Method is generated. Documentation taken from corresponding module. 1482 | * 1483 | * Asserts that a string ends with a given suffix. 1484 | * @see \Codeception\Module\AbstractAsserts::assertStringEndsWith() 1485 | */ 1486 | public function assertStringEndsWith(string $suffix, string $string, string $message = "") { 1487 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEndsWith', func_get_args())); 1488 | } 1489 | 1490 | 1491 | /** 1492 | * [!] Method is generated. Documentation taken from corresponding module. 1493 | * 1494 | * Asserts that the contents of a string is equal to the contents of a file. 1495 | * @see \Codeception\Module\AbstractAsserts::assertStringEqualsFile() 1496 | */ 1497 | public function assertStringEqualsFile(string $expectedFile, string $actualString, string $message = "") { 1498 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEqualsFile', func_get_args())); 1499 | } 1500 | 1501 | 1502 | /** 1503 | * [!] Method is generated. Documentation taken from corresponding module. 1504 | * 1505 | * Asserts that the contents of a string is equal to the contents of a file (canonicalizing). 1506 | * @see \Codeception\Module\AbstractAsserts::assertStringEqualsFileCanonicalizing() 1507 | */ 1508 | public function assertStringEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = "") { 1509 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEqualsFileCanonicalizing', func_get_args())); 1510 | } 1511 | 1512 | 1513 | /** 1514 | * [!] Method is generated. Documentation taken from corresponding module. 1515 | * 1516 | * Asserts that the contents of a string is equal to the contents of a file (ignoring case). 1517 | * @see \Codeception\Module\AbstractAsserts::assertStringEqualsFileIgnoringCase() 1518 | */ 1519 | public function assertStringEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = "") { 1520 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEqualsFileIgnoringCase', func_get_args())); 1521 | } 1522 | 1523 | 1524 | /** 1525 | * [!] Method is generated. Documentation taken from corresponding module. 1526 | * 1527 | * Asserts that a string matches a given format string. 1528 | * @see \Codeception\Module\AbstractAsserts::assertStringMatchesFormat() 1529 | */ 1530 | public function assertStringMatchesFormat(string $format, string $string, string $message = "") { 1531 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringMatchesFormat', func_get_args())); 1532 | } 1533 | 1534 | 1535 | /** 1536 | * [!] Method is generated. Documentation taken from corresponding module. 1537 | * 1538 | * Asserts that a string matches a given format file. 1539 | * @see \Codeception\Module\AbstractAsserts::assertStringMatchesFormatFile() 1540 | */ 1541 | public function assertStringMatchesFormatFile(string $formatFile, string $string, string $message = "") { 1542 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringMatchesFormatFile', func_get_args())); 1543 | } 1544 | 1545 | 1546 | /** 1547 | * [!] Method is generated. Documentation taken from corresponding module. 1548 | * 1549 | * 1550 | * @see \Codeception\Module\AbstractAsserts::assertStringNotContainsString() 1551 | */ 1552 | public function assertStringNotContainsString(string $needle, string $haystack, string $message = "") { 1553 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotContainsString', func_get_args())); 1554 | } 1555 | 1556 | 1557 | /** 1558 | * [!] Method is generated. Documentation taken from corresponding module. 1559 | * 1560 | * 1561 | * @see \Codeception\Module\AbstractAsserts::assertStringNotContainsStringIgnoringCase() 1562 | */ 1563 | public function assertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = "") { 1564 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotContainsStringIgnoringCase', func_get_args())); 1565 | } 1566 | 1567 | 1568 | /** 1569 | * [!] Method is generated. Documentation taken from corresponding module. 1570 | * 1571 | * Asserts that the contents of a string is not equal to the contents of a file. 1572 | * @see \Codeception\Module\AbstractAsserts::assertStringNotEqualsFile() 1573 | */ 1574 | public function assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = "") { 1575 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotEqualsFile', func_get_args())); 1576 | } 1577 | 1578 | 1579 | /** 1580 | * [!] Method is generated. Documentation taken from corresponding module. 1581 | * 1582 | * Asserts that the contents of a string is not equal to the contents of a file (canonicalizing). 1583 | * @see \Codeception\Module\AbstractAsserts::assertStringNotEqualsFileCanonicalizing() 1584 | */ 1585 | public function assertStringNotEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = "") { 1586 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotEqualsFileCanonicalizing', func_get_args())); 1587 | } 1588 | 1589 | 1590 | /** 1591 | * [!] Method is generated. Documentation taken from corresponding module. 1592 | * 1593 | * Asserts that the contents of a string is not equal to the contents of a file (ignoring case). 1594 | * @see \Codeception\Module\AbstractAsserts::assertStringNotEqualsFileIgnoringCase() 1595 | */ 1596 | public function assertStringNotEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = "") { 1597 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotEqualsFileIgnoringCase', func_get_args())); 1598 | } 1599 | 1600 | 1601 | /** 1602 | * [!] Method is generated. Documentation taken from corresponding module. 1603 | * 1604 | * Asserts that a string does not match a given format string. 1605 | * @see \Codeception\Module\AbstractAsserts::assertStringNotMatchesFormat() 1606 | */ 1607 | public function assertStringNotMatchesFormat(string $format, string $string, string $message = "") { 1608 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotMatchesFormat', func_get_args())); 1609 | } 1610 | 1611 | 1612 | /** 1613 | * [!] Method is generated. Documentation taken from corresponding module. 1614 | * 1615 | * Asserts that a string does not match a given format string. 1616 | * @see \Codeception\Module\AbstractAsserts::assertStringNotMatchesFormatFile() 1617 | */ 1618 | public function assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = "") { 1619 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotMatchesFormatFile', func_get_args())); 1620 | } 1621 | 1622 | 1623 | /** 1624 | * [!] Method is generated. Documentation taken from corresponding module. 1625 | * 1626 | * Asserts that a string starts not with a given prefix. 1627 | * @see \Codeception\Module\AbstractAsserts::assertStringStartsNotWith() 1628 | */ 1629 | public function assertStringStartsNotWith(string $prefix, string $string, string $message = "") { 1630 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsNotWith', func_get_args())); 1631 | } 1632 | 1633 | 1634 | /** 1635 | * [!] Method is generated. Documentation taken from corresponding module. 1636 | * 1637 | * Asserts that a string starts with a given prefix. 1638 | * @see \Codeception\Module\AbstractAsserts::assertStringStartsWith() 1639 | */ 1640 | public function assertStringStartsWith(string $prefix, string $string, string $message = "") { 1641 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsWith', func_get_args())); 1642 | } 1643 | 1644 | 1645 | /** 1646 | * [!] Method is generated. Documentation taken from corresponding module. 1647 | * 1648 | * Evaluates a PHPUnit\Framework\Constraint matcher object. 1649 | * 1650 | * @param mixed $value 1651 | * @see \Codeception\Module\AbstractAsserts::assertThat() 1652 | */ 1653 | public function assertThat($value, \PHPUnit\Framework\Constraint\Constraint $constraint, string $message = "") { 1654 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertThat', func_get_args())); 1655 | } 1656 | 1657 | 1658 | /** 1659 | * [!] Method is generated. Documentation taken from corresponding module. 1660 | * 1661 | * Asserts that a condition is true. 1662 | * 1663 | * @param mixed $condition 1664 | * 1665 | * @phpstan-assert true $condition 1666 | * @see \Codeception\Module\AbstractAsserts::assertTrue() 1667 | */ 1668 | public function assertTrue($condition, string $message = "") { 1669 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertTrue', func_get_args())); 1670 | } 1671 | 1672 | 1673 | /** 1674 | * [!] Method is generated. Documentation taken from corresponding module. 1675 | * 1676 | * Asserts that two XML files are equal. 1677 | * @see \Codeception\Module\AbstractAsserts::assertXmlFileEqualsXmlFile() 1678 | */ 1679 | public function assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message = "") { 1680 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlFileEqualsXmlFile', func_get_args())); 1681 | } 1682 | 1683 | 1684 | /** 1685 | * [!] Method is generated. Documentation taken from corresponding module. 1686 | * 1687 | * Asserts that two XML files are not equal. 1688 | * @see \Codeception\Module\AbstractAsserts::assertXmlFileNotEqualsXmlFile() 1689 | */ 1690 | public function assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = "") { 1691 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlFileNotEqualsXmlFile', func_get_args())); 1692 | } 1693 | 1694 | 1695 | /** 1696 | * [!] Method is generated. Documentation taken from corresponding module. 1697 | * 1698 | * Asserts that two XML documents are equal. 1699 | * 1700 | * @param \DOMDocument|string $actualXml 1701 | * @see \Codeception\Module\AbstractAsserts::assertXmlStringEqualsXmlFile() 1702 | */ 1703 | public function assertXmlStringEqualsXmlFile(string $expectedFile, $actualXml, string $message = "") { 1704 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlStringEqualsXmlFile', func_get_args())); 1705 | } 1706 | 1707 | 1708 | /** 1709 | * [!] Method is generated. Documentation taken from corresponding module. 1710 | * 1711 | * Asserts that two XML documents are equal. 1712 | * 1713 | * @param \DOMDocument|string $expectedXml 1714 | * @param \DOMDocument|string $actualXml 1715 | * @see \Codeception\Module\AbstractAsserts::assertXmlStringEqualsXmlString() 1716 | */ 1717 | public function assertXmlStringEqualsXmlString($expectedXml, $actualXml, string $message = "") { 1718 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlStringEqualsXmlString', func_get_args())); 1719 | } 1720 | 1721 | 1722 | /** 1723 | * [!] Method is generated. Documentation taken from corresponding module. 1724 | * 1725 | * Asserts that two XML documents are not equal. 1726 | * 1727 | * @param \DOMDocument|string $actualXml 1728 | * @see \Codeception\Module\AbstractAsserts::assertXmlStringNotEqualsXmlFile() 1729 | */ 1730 | public function assertXmlStringNotEqualsXmlFile(string $expectedFile, $actualXml, string $message = "") { 1731 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlStringNotEqualsXmlFile', func_get_args())); 1732 | } 1733 | 1734 | 1735 | /** 1736 | * [!] Method is generated. Documentation taken from corresponding module. 1737 | * 1738 | * Asserts that two XML documents are not equal. 1739 | * 1740 | * @param \DOMDocument|string $expectedXml 1741 | * @param \DOMDocument|string $actualXml 1742 | * @see \Codeception\Module\AbstractAsserts::assertXmlStringNotEqualsXmlString() 1743 | */ 1744 | public function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, string $message = "") { 1745 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlStringNotEqualsXmlString', func_get_args())); 1746 | } 1747 | 1748 | 1749 | /** 1750 | * [!] Method is generated. Documentation taken from corresponding module. 1751 | * 1752 | * Fails a test with the given message. 1753 | * @see \Codeception\Module\AbstractAsserts::fail() 1754 | */ 1755 | public function fail(string $message = "") { 1756 | return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args())); 1757 | } 1758 | 1759 | 1760 | /** 1761 | * [!] Method is generated. Documentation taken from corresponding module. 1762 | * 1763 | * Mark the test as incomplete. 1764 | * @see \Codeception\Module\AbstractAsserts::markTestIncomplete() 1765 | */ 1766 | public function markTestIncomplete(string $message = "") { 1767 | return $this->getScenario()->runStep(new \Codeception\Step\Action('markTestIncomplete', func_get_args())); 1768 | } 1769 | 1770 | 1771 | /** 1772 | * [!] Method is generated. Documentation taken from corresponding module. 1773 | * 1774 | * Mark the test as skipped. 1775 | * @see \Codeception\Module\AbstractAsserts::markTestSkipped() 1776 | */ 1777 | public function markTestSkipped(string $message = "") { 1778 | return $this->getScenario()->runStep(new \Codeception\Step\Action('markTestSkipped', func_get_args())); 1779 | } 1780 | } 1781 | -------------------------------------------------------------------------------- /tests/unit.suite.yml: -------------------------------------------------------------------------------- 1 | # Codeception Test Suite Configuration 2 | # 3 | # Suite for unit or integration tests. 4 | 5 | actor: UnitTester 6 | modules: 7 | enabled: 8 | - Asserts 9 | - \Helper\Unit 10 | step_decorators: ~ -------------------------------------------------------------------------------- /tests/unit/WordpressViteAssetsTest.php: -------------------------------------------------------------------------------- 1 | basePath = realpath($this->baseUrl); 20 | $this->viteAssets = new Assets($this->manifest, $this->baseUrl); 21 | } 22 | 23 | protected function _after() 24 | { 25 | } 26 | 27 | // tests 28 | public function testGetScriptTag() 29 | { 30 | $actual = $this->viteAssets->getScriptTag("demo.ts"); 31 | $expected = ""; 32 | 33 | $this->assertEquals($actual, $expected); 34 | } 35 | 36 | public function testGetScriptTagSHA256() 37 | { 38 | $viteAssets = new Assets($this->manifest, $this->baseUrl, "sha256"); 39 | 40 | $actual = $viteAssets->getScriptTag("demo.ts"); 41 | $expected = ""; 42 | 43 | $this->assertEquals($actual, $expected); 44 | } 45 | 46 | public function testGetScriptTagSHA384() 47 | { 48 | $viteAssets = new Assets($this->manifest, $this->baseUrl, "sha384"); 49 | 50 | $actual = $viteAssets->getScriptTag("demo.ts"); 51 | $expected = ""; 52 | 53 | $this->assertEquals($actual, $expected); 54 | } 55 | 56 | public function testGetScriptTagSHA512() 57 | { 58 | $viteAssets = new Assets($this->manifest, $this->baseUrl, "sha512"); 59 | 60 | $actual = $viteAssets->getScriptTag("demo.ts"); 61 | $expected = ""; 62 | 63 | $this->assertEquals($actual, $expected); 64 | } 65 | 66 | public function testGetScriptTagWithoutOptionalAttributes() 67 | { 68 | $actual = $this->viteAssets->getScriptTag("demo.ts", ["crossorigin" => false, "integrity" => false]); 69 | $expected = ""; 70 | 71 | $this->assertEquals($actual, $expected); 72 | } 73 | 74 | public function testGetScriptTagWithoutCrossoriginAttribute() 75 | { 76 | $actual = $this->viteAssets->getScriptTag("demo.ts", ["crossorigin" => false]); 77 | $expected = ""; 78 | 79 | $this->assertEquals($actual, $expected); 80 | } 81 | 82 | public function testGetScriptTagWithoutIntegrityAttribute() 83 | { 84 | $actual = $this->viteAssets->getScriptTag("demo.ts", ["integrity" => false]); 85 | $expected = ""; 86 | 87 | $this->assertEquals($actual, $expected); 88 | } 89 | 90 | public function testGetStyletags() 91 | { 92 | foreach ($this->viteAssets->getStyleTags("demo.ts") as $actual) { 93 | $expected = "basePath}/assets/index.deadbeef.css\" crossorigin integrity=\"sha256-EEEKapOxnF8qZUxsx0ksgdBVnEB+8dXUJvH75TwCWvU=\" />"; 94 | 95 | $this->assertEquals($actual, $expected); 96 | } 97 | } 98 | 99 | public function testGetStyletagsSHA256() 100 | { 101 | $viteAssets = new Assets($this->manifest, $this->baseUrl, "sha256"); 102 | 103 | foreach ($viteAssets->getStyleTags("demo.ts") as $actual) { 104 | $expected = "basePath}/assets/index.deadbeef.css\" crossorigin integrity=\"sha256-EEEKapOxnF8qZUxsx0ksgdBVnEB+8dXUJvH75TwCWvU=\" />"; 105 | 106 | $this->assertEquals($actual, $expected); 107 | } 108 | } 109 | 110 | public function testGetStyletagsSHA384() 111 | { 112 | $viteAssets = new Assets($this->manifest, $this->baseUrl, "sha384"); 113 | 114 | foreach ($viteAssets->getStyleTags("demo.ts") as $actual) { 115 | $expected = "basePath}/assets/index.deadbeef.css\" crossorigin integrity=\"sha384-hRJLv1qN+U3dkKJIw8ANFbwPS/ED0NHZfZU96sK3vRe3evsIbIxjnkoFcJeryuVC\" />"; 116 | 117 | $this->assertEquals($actual, $expected); 118 | } 119 | } 120 | 121 | public function testGetStyletagsSHA512() 122 | { 123 | $viteAssets = new Assets($this->manifest, $this->baseUrl, "sha512"); 124 | 125 | foreach ($viteAssets->getStyleTags("demo.ts") as $actual) { 126 | $expected = "basePath}/assets/index.deadbeef.css\" crossorigin integrity=\"sha512-vmI3y876ZfoogL2eJuRJy4ToOnrfwPVE7T9yMlhJp5lpSGHZ3ejDNqd7A0QYFlk0/SOugOwB1x0FCWqO95pz4Q==\" />"; 127 | 128 | $this->assertEquals($actual, $expected); 129 | } 130 | } 131 | 132 | public function testGetStyletagsWithoutAttributes() 133 | { 134 | foreach ($this->viteAssets->getStyleTags("demo.ts", ["crossorigin" => false, "integrity" => false]) as $actual) { 135 | $expected = "basePath}/assets/index.deadbeef.css\" />"; 136 | 137 | $this->assertEquals($actual, $expected); 138 | } 139 | } 140 | 141 | public function testGetStyletagsWithoutCrossoriginAttribute() 142 | { 143 | foreach ($this->viteAssets->getStyleTags("demo.ts", ["crossorigin" => false]) as $actual) { 144 | $expected = "basePath}/assets/index.deadbeef.css\" integrity=\"sha256-EEEKapOxnF8qZUxsx0ksgdBVnEB+8dXUJvH75TwCWvU=\" />"; 145 | 146 | $this->assertEquals($actual, $expected); 147 | } 148 | } 149 | 150 | public function testGetStyletagsWithoutCrossoriginAttributeSHA256() 151 | { 152 | $viteAssets = new Assets($this->manifest, $this->baseUrl, "sha256"); 153 | 154 | foreach ($viteAssets->getStyleTags("demo.ts", ["crossorigin" => false]) as $actual) { 155 | $expected = "basePath}/assets/index.deadbeef.css\" integrity=\"sha256-EEEKapOxnF8qZUxsx0ksgdBVnEB+8dXUJvH75TwCWvU=\" />"; 156 | 157 | $this->assertEquals($actual, $expected); 158 | } 159 | } 160 | 161 | public function testGetStyletagsWithoutCrossoriginAttributeSHA384() 162 | { 163 | $viteAssets = new Assets($this->manifest, $this->baseUrl, "sha384"); 164 | 165 | foreach ($viteAssets->getStyleTags("demo.ts", ["crossorigin" => false]) as $actual) { 166 | $expected = "basePath}/assets/index.deadbeef.css\" integrity=\"sha384-hRJLv1qN+U3dkKJIw8ANFbwPS/ED0NHZfZU96sK3vRe3evsIbIxjnkoFcJeryuVC\" />"; 167 | 168 | $this->assertEquals($actual, $expected); 169 | } 170 | } 171 | 172 | public function testGetStyletagsWithoutCrossoriginAttributeSHA512() 173 | { 174 | $viteAssets = new Assets($this->manifest, $this->baseUrl, "sha512"); 175 | 176 | foreach ($viteAssets->getStyleTags("demo.ts", ["crossorigin" => false]) as $actual) { 177 | $expected = "basePath}/assets/index.deadbeef.css\" integrity=\"sha512-vmI3y876ZfoogL2eJuRJy4ToOnrfwPVE7T9yMlhJp5lpSGHZ3ejDNqd7A0QYFlk0/SOugOwB1x0FCWqO95pz4Q==\" />"; 178 | 179 | $this->assertEquals($actual, $expected); 180 | } 181 | } 182 | 183 | public function testGetStyletagsWithoutIntegrityAttribute() 184 | { 185 | foreach ($this->viteAssets->getStyleTags("demo.ts", ["integrity" => false]) as $actual) { 186 | $expected = "basePath}/assets/index.deadbeef.css\" crossorigin />"; 187 | 188 | $this->assertEquals($actual, $expected); 189 | } 190 | } 191 | 192 | public function testGetPreloadtags() 193 | { 194 | foreach ($this->viteAssets->getPreloadTags("demo.ts") as $actual) { 195 | $expected = "basePath}/assets/vendor.deadbeef.js\" />"; 196 | 197 | $this->assertEquals($actual, $expected); 198 | } 199 | } 200 | } 201 | --------------------------------------------------------------------------------