Laravel开发-package-phpunit

  • u7_443487
    了解作者
  • 10.3KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 09:51
    上传日期
Laravel开发-package-phpunit Laravel Package Development Phpunit公司
Laravel开发-package-phpunit .zip
  • package-phpunit-master
  • .gitignore
    109B
  • README.md
    1.7KB
  • phpcs.xml
    792B
  • .bowerrc
    45B
  • tests
  • DatabaseTest.php
    931B
  • traits
  • Laravel.php
    3.1KB
  • bootstrap.php
    1KB
  • phpunit.xml
    790B
  • elixir.json
    181B
  • database
  • migrations
  • 2016_01_29_203356_create_tests_table.php
    684B
  • composer.json
    834B
  • .php_cs
    2KB
  • .gitattributes
    61B
  • package.json
    159B
  • .nitpick.json
    44B
  • ruleset.xml
    958B
  • LICENSE.md
    1.1KB
  • .travis.yml
    187B
  • .editorconfig
    193B
  • gulpfile.js
    579B
内容介绍
# Laravel Package Develop Phpunit ## Install ### step1 composer.json ``` require-dev: { "recca0120/package-phpunit": "~0.2.1" } ``` composer install or composer update ### step2 copy phpunit.xml, tests folder to root ### step3 execute phpunit ## Example This package is auto setup database [sqlite] you can add migrations to database/migrations and in your test case add code ```php class DatabaseTest extends PHPUnit_Framework_TestCase { public function setUp() { $app = App::getInstance(); $app->migrate('up'); } public function tearDown() { $app = App::getInstance(); $app->migrate('down'); } } ``` ## FULL DEMO ```php use Illuminate\Database\Eloquent\Model; class DatabaseTest extends PHPUnit_Framework_TestCase { public function setUp() { $app = App::getInstance(); $app->migrate('up'); } public function tearDown() { $app = App::getInstance(); $app->migrate('down'); } public function test_app_environment() { $this->assertEquals(App::environment(), 'testing'); } public function test_insert_into_database() { $data = [ 'test1' => 'test1', 'test2' => 'test2', 'test3' => 'test3', ]; $test = Test::create($data); // $result = $test->toArray(); $this->assertEquals($test->id, 1); $this->assertEquals($test->test1, $data['test1']); $this->assertEquals($test->test2, $data['test2']); $this->assertEquals($test->test3, $data['test3']); } } class Test extends Model { protected $guarded = ['id']; } ``` ## notice ### sqlite is not support alter table
评论
    相关推荐