Skip to content

Commit 7a10451

Browse files
committed
Optimize for composer package
Change the directory structure to psr-4.0 to automate loading based on namespace. Also fix the PHPUnit test for 6.*.
1 parent c79cbe0 commit 7a10451

File tree

4 files changed

+15
-44
lines changed

4 files changed

+15
-44
lines changed

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
"phpunit/phpunit": "^6.0"
66
},
77
"autoload": {
8-
"psr-0": {
9-
"ntwIndia": ""
10-
},
11-
"files": ["ntwIndia/class-ntw-india.php"]
8+
"psr-4": {
9+
"ntwIndia\\": "src/"
10+
}
1211
}
1312
}

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<phpunit colors="true">
33
<testsuites>
44
<testsuite name="Application Test Suite">
5-
<directory>./ntwIndia/Test/</directory>
5+
<directory>./test/</directory>
66
</testsuite>
77
</testsuites>
88
</phpunit>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* PHP Library
77
*
88
* @author Swashata Ghosh <swashata@iptms.co>
9-
* @license GPLv3
9+
* @license GPL-v3.0
1010
*/
1111
class NTW_India {
1212
/**
Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
2-
namespace ntwIndia\Test;
3-
42
class NTW_India_Test extends \PHPUnit\Framework\TestCase {
53
public $ntw;
64

7-
public function __construct() {
5+
public function setUp() {
86
$this->ntw = new \ntwIndia\NTW_India();
97
}
108

@@ -37,36 +35,7 @@ public function test_more_than_hundred() {
3735
}
3836

3937
public function test_less_than_hundred() {
40-
$num_to_wd = array(
41-
'0' => 'Zero',
42-
'1' => 'One',
43-
'2' => 'Two',
44-
'3' => 'Three',
45-
'4' => 'Four',
46-
'5' => 'Five',
47-
'6' => 'Six',
48-
'7' => 'Seven',
49-
'8' => 'Eight',
50-
'9' => 'Nine',
51-
'10' => 'Ten',
52-
'11' => 'Eleven',
53-
'12' => 'Twelve',
54-
'13' => 'Thirteen',
55-
'14' => 'Fourteen',
56-
'15' => 'Fifteen',
57-
'16' => 'Sixteen',
58-
'17' => 'Seventeen',
59-
'18' => 'Eighteen',
60-
'19' => 'Nineteen',
61-
'20' => 'Twenty',
62-
'30' => 'Thirty',
63-
'40' => 'Forty',
64-
'50' => 'Fifty',
65-
'60' => 'Sixty',
66-
'70' => 'Seventy',
67-
'80' => 'Eighty',
68-
'90' => 'Ninety',
69-
);
38+
$num_to_wd = $this->get_num_to_word();
7039

7140
foreach ( $num_to_wd as $num => $wd ) {
7241
$this->assertEquals( $wd, $this->ntw->num_to_word( $num ) );
@@ -80,7 +49,14 @@ public function test_zero_value() {
8049
}
8150

8251
public function test_num_to_wd_small() {
83-
$num_to_wd = array(
52+
$num_to_wd = $this->get_num_to_word();
53+
foreach ( $num_to_wd as $num => $wd ) {
54+
$this->assertEquals( $wd, $this->ntw->num_to_wd_small( $num ) );
55+
}
56+
}
57+
58+
private function get_num_to_word() {
59+
return array(
8460
'0' => 'Zero',
8561
'1' => 'One',
8662
'2' => 'Two',
@@ -110,9 +86,5 @@ public function test_num_to_wd_small() {
11086
'80' => 'Eighty',
11187
'90' => 'Ninety',
11288
);
113-
114-
foreach ( $num_to_wd as $num => $wd ) {
115-
$this->assertEquals( $wd, $this->ntw->num_to_wd_small( $num ) );
116-
}
11789
}
11890
}

0 commit comments

Comments
 (0)