Skip to content

Commit

Permalink
docs: reorder test section, add sample test
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Aug 31, 2018
1 parent 80b0bc3 commit 03616f3
Showing 1 changed file with 67 additions and 29 deletions.
96 changes: 67 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ It helps you be even more lazier! `phint` is work in progress and the plan is to

![Phint Preview](https://imgur.com/F6PkX9Z.png "Phint Preview")

[Installation](#installation) · [Features](#features) · [Usage](#usage) · [phint init](#init) · [phint update](#update) · [phint test](#test) · [phint docs](#docs) · [Templating](#templating)
[Installation](#installation) · [Features](#features) · [Usage](#usage) · [phint init](#init) · [phint update](#update) · [phint docs](#docs) · [phint test](#test) · [Templating](#templating)

## Installation

Expand Down Expand Up @@ -175,34 +175,6 @@ Usage Examples:
phint u --rollback Also rolls back to prev version
```

---
## test

> alias t
Generate test files with proper classes and test methods analogous to their source counterparts.
If a test class already exists, it is skipped. In future we may append test stubs for new methods.

Ideally you would run it on existing project **or** after you create/update `src/` files.

***Parameters:***

```
Options:
[-a, --with-abstract] Create stub for abstract/interface class
[-h, --help] Show help
[-n, --naming] Test method naming format
(t: testMethod | m: test_method | i: it_tests_)
[-p, --phpunit] Base PHPUnit class to extend from
[-s, --no-setup] Dont add setup method
[-t, --no-teardown] Dont add teardown method
Usage Examples:
phint test -n i With `it_` naming
phint t --no-teardown Without `tearDown()`
phint test -a With stubs for abstract/interface
```

---
## docs

Expand Down Expand Up @@ -325,6 +297,72 @@ $dummy->alpha('john', true);
// '...'
```

---
## test

> alias t
Generate test files with proper classes and test methods analogous to their source counterparts.
If a test class already exists, it is skipped. In future we may append test stubs for new methods.

Ideally you would run it on existing project **or** after you create/update `src/` files.

***Parameters:***

```
Options:
[-a, --with-abstract] Create stub for abstract/interface class
[-h, --help] Show help
[-n, --naming] Test method naming format
(t: testMethod | m: test_method | i: it_tests_)
[-p, --phpunit] Base PHPUnit class to extend from
[-s, --no-setup] Dont add setup method
[-t, --no-teardown] Dont add teardown method
Usage Examples:
phint test -n i With `it_` naming
phint t --no-teardown Without `tearDown()`
phint test -a With stubs for abstract/interface
```

### Sample test

Generated `tests/Dummy.php` for [Abc\\Dummy](#sample-docs) above:

```php
<?php

namespace Abc\Test;

use Abc\Dummy;
use PHPUnit\Framework\TestCase as TestCase;

/**
* Auto generated by `phint test`.
*/
class DummyTest extends TestCase
{
/**
* @var Dummy
*/
protected $dummy;

public function setUp()
{
parent::setUp();

$this->dummy = new Dummy;
}

public function testAlpha()
{
$actual = $this->dummy->alpha();

// $this->assertSame('', $actual);
}
}
```

---
## Templating

Expand Down

0 comments on commit 03616f3

Please sign in to comment.