承接 holyshared/peridot-temporary-plugin 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

holyshared/peridot-temporary-plugin

Composer 安装命令:

composer require holyshared/peridot-temporary-plugin

包简介

Temporary file / directory plugin for peridot-php

README 文档

README

It provides an api to create a temporary directory or file.
Directory of file will be deleted at the end of the test.

Build Status HHVM Status Coverage Status Scrutinizer Code Quality Dependency Status

Basic usage

First will first register the plugin.
Edit the peridot.php, write the code to register.

use holyshared\peridot\temporary\TemporaryPlugin;

return function(EventEmitterInterface $emitter)
{
    TemporaryPlugin::create()->registerTo($emitter);
};

Create a temporary directory

Create a temporary directory, call the makeDirectory method.
Directory name is generated by UUID, use the id.

Permissions can be specified in the argument.

beforeEach(function() {
    $this->temp = $this->makeDirectory(); //return holyshared\peridot\temporary\TemporaryDirectory instance
});
it('create temporary directory', function() {
    expect($this->temp->exists())->toBeTrue();
});

or

beforeEach(function() {
    $this->temp = $this->makeDirectory(0755);
});
it('create temporary directory', function() {
    expect($this->temp->exists())->toBeTrue();
});

Create a temporary file

Create a temporary file, call the makeFile method.
File name is generated by UUID, use the id.

Permissions can be specified in the argument.

beforeEach(function() {
    $this->temp = $this->makeFile(); //return holyshared\peridot\temporary\TemporaryFile instance
});
it('create temporary file', function() {
    expect($this->temp->exists())->toBeTrue();
});

or

beforeEach(function() {
    $this->temp = $this->makeFile(0755);
});
it('create temporary file', function() {
    expect($this->temp->exists())->toBeTrue();
});

Write to a temporary file

You can output the data to a temporary file in the write or writeln method of TemporaryFile instance.

beforeEach(function() {
    $this->tempDirectory = $this->makeDirectory();
    $this->tempFile = $this->tempDirectory->createNewFile('report.txt');

    $this->tempFile->writeln('Hello world!!');
    $this->tempFile->writeln('Hello world!!');
});
afterEach(function() {
    $this->cleanUpTemporary();
});

or

beforeEach(function() {
    $tempDirectory = $this->makeDirectory();
    $tempFilePath = $tempDirectory->resolvePath('report.txt'); //File not created!!

    $tempFile = new SplFileObject($tempFilePath, 'w');
    $tempFile->fwrite('Hello world!!');
    $tempFile->fwrite('Hello world!!');
    $tempFile = null;
});

Running tests

Run with the following command.

composer test

统计信息

  • 总下载量: 1.2k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 11
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固