vendi-advertising/vendi-sanity-tester 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vendi-advertising/vendi-sanity-tester

Composer 安装命令:

composer require vendi-advertising/vendi-sanity-tester

包简介

Utility to test for sanity of underlying system during install.

README 文档

README

Sample

<?php

use Vendi\SanityTester\TestGroup;
use Vendi\SanityTester\TestRunner;
use Vendi\SanityTester\Tests\FileSystemTest;
use Vendi\SanityTester\Tests\PhpVersionTest;

define('VENDI_SANITY_ROOT', __DIR__ );

//The sanity checker is controlled via composer now
if(!file_exists(VENDI_SANITY_ROOT . '/vendor/autoload.php')){
    echo '<h1>Composer not loaded </h1>';
    exit;
}

//Load the plugin's autoloader
require_once VENDI_SANITY_ROOT . '/vendor/autoload.php';

//Make sure that the SanityTester actually exists
if(!class_exists('Vendi\SanityTester\TestRunner')){
    echo '<h1>Vendi SanityTester not found</h1>';
    exit;
}


//Now we can finally use the tester!!

          //The root runner
$runner = (new TestRunner('Sanity Tests'))

            //Add test group
            ->with_test_group(
                (new TestGroup('Composer'))

                    //Add individual tests
                    ->with_test(new FileSystemTest('Lock',          VENDI_SANITY_ROOT . '/composer.lock'))
                    ->with_test(new FileSystemTest('Vendor folder', VENDI_SANITY_ROOT . '/vendor/composer/'))
            )
            ->with_test_group(
                (new TestGroup('PHP'))
                    ->with_test(new PhpVersionTest(7, [1,2,3]))
            )
;

$runner->run();

WordPress

If you need to test WordPress features it is up to you to make sure that WordPress is booted up first. The simplest way is usually to load wp-load.php. For instance, if your test file is in the root of a plugin at a URL that you are manually calling you can probably just use:

define( 'WP_USE_THEMES', false );
require '../../../wp-load.php' ;

The define line is essentially a way to tell WordPress that you want a lite mode.

You can then use the WordPressPlugin test:

$runner = (new TestRunner('Sanity Tests'))
            ->with_test_group(
                (new TestGroup('WordPress Plugins'))
                    ->with_test(new WordPressPlugin('ACF Pro', 'advanced-custom-fields-pro/acf.php'))
            )
;

统计信息

  • 总下载量: 29
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固