Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ jobs:
cd /tmp/wordpress-develop
php tests/phpunit/includes/install.php wp-tests-config.php

- name: Run tests
run: composer test -- --exclude-group problematic
- name: Run quality checks
run: composer quality

- name: Run tests with coverage
run: composer test:coverage
Expand Down
22 changes: 16 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@

# file: ~/.gitignore_global
# Operating system and IDE files
.DS_Store
.idea/

# PHP dependencies and archives
/vendor/
*.phar
.phpunit.cache
vendor
lib/
assets/node_modules/

# JavaScript dependencies
/assets/node_modules/

# Test and coverage artifacts
/.phpunit.cache/
/.phpunit.result.cache
/test-results.xml
/coverage/

# Runtime-installed third-party framework
/lib/
19 changes: 15 additions & 4 deletions CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
## 🎯 Цели CI Pipeline

- **Автоматизированное тестирование** на множестве версий PHP
- **Проверка стиля кода** через Laravel Pint с Laravel preset
- **Статический анализ** через PHPStan и WordPress stubs
- **Проверка совместимости** с WordPress test suite
- **Анализ покрытия кода** и загрузка отчетов
- **Предотвращение регрессий** перед merge в main/develop
Expand Down Expand Up @@ -200,22 +202,31 @@ services:
- wp-tests-config.php правильно настроен
- База данных доступна

### Шаг 9: Запуск тестов
### Шаг 9: Запуск quality gate

```yaml
- name: Run tests
run: composer test -- --exclude-group problematic
- name: Run quality checks
run: composer quality
```

**Что делает:**
- Проверяет `composer.json`, форматирование Laravel Pint и PHPStan
- Запускает все тесты через Composer скрипт
- Исключает тесты с группой @group problematic

**Требования:**
- composer.json с настроенным скриптом test
- Все зависимости установлены
- WP_TESTS_DIR настроена

### Локальные проверки качества

```bash
composer format # исправить форматирование Laravel preset
composer format:check # проверить форматирование без изменений
composer static-analysis
composer quality # полный quality gate
```

### Шаг 10: Запуск тестов с покрытием (только PHP 8.2)

```yaml
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ npm run dev # Development mode with watch
## ✅ Requirements

- WordPress 6.6+
- PHP 7.4+
- PHP 8.2+

## 🧪 Testing

Expand Down Expand Up @@ -366,7 +366,7 @@ npm run dev # Режим разработки с watch
## ✅ Требования

- WordPress 6.6+
- PHP 7.4+
- PHP 8.2+

## 🧪 Тестирование

Expand Down
15 changes: 10 additions & 5 deletions assets/js/lazy-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
}

function init() {
// Check for Intersection Observer
if (!window.IntersectionObserver) {
console.warn('Lazy Loading: Intersection Observer not supported');
const images = document.querySelectorAll('img.lazy-img[data-src]');
if (images.length === 0) {
return;
}

const images = document.querySelectorAll('img.lazy-img[data-src]');
if (images.length === 0) {
if (!window.IntersectionObserver) {
images.forEach(loadImage);
return;
}

Expand All @@ -43,6 +42,12 @@
const src = img.getAttribute('data-src');
if (!src) return;

const srcset = img.getAttribute('data-srcset');
if (srcset) {
img.setAttribute('srcset', srcset);
img.removeAttribute('data-srcset');
}

img.src = src;
img.removeAttribute('data-src');
img.classList.remove('lazy-img');
Expand Down
29 changes: 12 additions & 17 deletions autoloader.php
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
<?php
/**
* @year: 2019-03-27
*/

add_action( 'admin_head', function () {
if ( 'plugins' === get_current_screen()->id && !class_exists( 'CSF' ) ){
?>
add_action('admin_head', function () {
if (get_current_screen()->id === 'plugins' && ! class_exists('CSF')) {
?>
<div id="message" class="updated notice is-dismissible"><p>
To work <b>#1 RW WordPress AddOn</b> plugin, please download and install <a href="https://github.com/Codestar/codestar-framework" target="_blank">Codestar Framework</a>.
</p></div>
<?php
}
}
});


/**
* Include all php file in subfolder
*/
foreach ( glob( RW_PLUGIN_DIR . 'functions/*.php' ) as $file ){
foreach (glob(RW_PLUGIN_DIR.'functions/*.php') as $file) {
$file = basename($file);
require RW_PLUGIN_DIR . 'functions/' . $file;
require RW_PLUGIN_DIR.'functions/'.$file;
}


/**
* Include all php file in subfolder
*/
foreach ( glob( RW_PLUGIN_DIR . 'functions/*/*.php' ) as $file ){
include_once $file;
foreach (glob(RW_PLUGIN_DIR.'functions/*/*.php') as $file) {
include_once $file;
}

/*foreach ( glob( RW_PLUGIN_DIR . 'ext/*.php' ) as $file ){
add_action('plugins_loaded', function () use ($file) {
include_once $file;
});
}*/
add_action('plugins_loaded', function () use ($file) {
include_once $file;
});
}*/
13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@
}
],
"require": {
"php": "^8.2"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
"mockery/mockery": "^1.4",
"pestphp/pest": "^2.0",
"fakerphp/faker": "^1.23"
"fakerphp/faker": "^1.23",
"laravel/pint": "^1.18",
"phpstan/phpstan": "^2.1",
"php-stubs/wordpress-stubs": "^6.8",
"szepeviktor/phpstan-wordpress": "^2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -26,7 +31,11 @@
},
"scripts": {
"test": "pest tests/Unit/LazyLoadingTest.php tests/Unit/FactoriesTest.php tests/Unit/ModuleSystemTest.php tests/Unit/ExampleTest.php tests/Feature/SmokeTest.php tests/Feature/ExampleTest.php",
"test:coverage": "pest --coverage tests/Unit/LazyLoadingTest.php tests/Unit/FactoriesTest.php tests/Unit/ModuleSystemTest.php tests/Unit/ExampleTest.php tests/Feature/SmokeTest.php tests/Feature/ExampleTest.php"
"test:coverage": "pest --coverage tests/Unit/LazyLoadingTest.php tests/Unit/FactoriesTest.php tests/Unit/ModuleSystemTest.php tests/Unit/ExampleTest.php tests/Feature/SmokeTest.php tests/Feature/ExampleTest.php",
"format": "pint",
"format:check": "pint --test",
"static-analysis": "phpstan analyse --memory-limit=1G",
"quality": "@composer validate --strict && @format:check && @static-analysis && @test"
},
"config": {
"allow-plugins": {
Expand Down
Loading
Loading