承接 cekurte/tdd 相关项目开发

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

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

cekurte/tdd

最新稳定版本:v1.0.2

Composer 安装命令:

composer require cekurte/tdd

包简介

PHPUnit TestCase

README 文档

README

Build Status Code Climate Coverage Status Latest Stable Version License SensioLabsInsight

  • Just a simple extension to the PHPUnit library.
  • Currently this package contains only support for one TestCase scenario ReflectionTestCase contribute with this project!

Installation

  • The package is available on Packagist.
  • The source files is PSR-2 compatible.
  • Autoloading is PSR-4 compatible.
composer require cekurte/tdd

If you liked of this library, give me a star =).

Documentation

This library was created to permit that developers write php unit tests using a common base class, including initially the following tasks:

  • Set a private, protected or public property value;
  • Get a private, protected or public property value;
  • Call a private, protected or public method.

Setting a property value

To set a property value (independently of your visibility) you can use the method ReflectionTestCase::propertySetValue like the following example:

<?php

namespace Your\Namespace;

use Cekurte\Tdd\ReflectionTestCase;

class YourClassTest extends ReflectionTestCase
{
    public function testAnything()
    {
        // Instance of a class that has one
        // private property named "yourPrivateProperty".
        $instance = new YourClass();

        // Set the value "newValue" to the property
        // "yourPrivateProperty".
        $this->propertySetValue(
            $instance,
            'yourPrivateProperty',
            'newValue'
        );

        // ...
    }
}

Getting a property value

To get a property value (independently of your visibility) you can use the method ReflectionTestCase::propertyGetValue like the following example:

<?php

namespace Your\Namespace;

use Cekurte\Tdd\ReflectionTestCase;

class YourClassTest extends ReflectionTestCase
{
    public function testAnything()
    {
        // Instance of a class that has one
        // private property named "yourPrivateProperty".
        $instance = new YourClass();

        // Get the value of the property
        // "yourPrivateProperty".
        $currentValue = $this->propertyGetValue(
            $instance,
            'yourPrivateProperty'
        );

        // ...
    }
}

Calling a method

To call a method (independently of your visibility) you can use the method ReflectionTestCase::invokeMethod like the following example:

<?php

namespace Your\Namespace;

use Cekurte\Tdd\ReflectionTestCase;

class YourClassTest extends ReflectionTestCase
{
    public function testAnything()
    {
        // Instance of a class that has one
        // private property named "yourPrivateMethod".
        $instance = new YourClass();

        // Call the method
        // "yourPrivateMethod".
        $valueReturned = $this->invokeMethod(
            $instance,
            'yourPrivateMethod',
            ['param1', 'param2', 'paramN']
        );

        // ...
    }
}

Contributing

  1. Give me a star =)
  2. Fork it
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Make your changes
  5. Run the tests, adding new ones for your own code if necessary (vendor/bin/phpunit)
  6. Commit your changes (git commit -am 'Added some feature')
  7. Push to the branch (git push origin my-new-feature)
  8. Create new Pull Request

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-17