PSR-4, Composer and PHPUnit autoloading
This commit is contained in:
parent
3161c8e661
commit
e35e2f3e0f
5 changed files with 38 additions and 5 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/vendor/
|
20
composer.json
Normal file
20
composer.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "joshtronic/php-sort",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"platform": {
|
||||
"php": ">=5.3"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Pickles\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Pickles\\Tests\\": "tests"
|
||||
}
|
||||
}
|
||||
}
|
5
phpcs.xml
Normal file
5
phpcs.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version='1.0'?>
|
||||
<ruleset>
|
||||
<exclude-pattern>vendor/*</exclude-pattern>
|
||||
<rule ref='PSR2' />
|
||||
</ruleset>
|
4
phpunit.xml
Normal file
4
phpunit.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<phpunit bootstrap="./vendor/autoload.php">
|
||||
<directory>./tests</directory>
|
||||
</phpunit>
|
|
@ -1,6 +1,10 @@
|
|||
<?php
|
||||
|
||||
class SortTest extends PHPUnit_Framework_TestCase
|
||||
namespace Pickles\Tests;
|
||||
|
||||
use Pickles\Sort;
|
||||
|
||||
class SortTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testByNameASC()
|
||||
{
|
||||
|
@ -20,7 +24,7 @@ class SortTest extends PHPUnit_Framework_TestCase
|
|||
['name' => 'gamma'],
|
||||
];
|
||||
|
||||
Pickles\Sort::by('name', $shuffled);
|
||||
Sort::by('name', $shuffled);
|
||||
|
||||
$this->assertEquals($sorted, $shuffled);
|
||||
}
|
||||
|
@ -43,7 +47,7 @@ class SortTest extends PHPUnit_Framework_TestCase
|
|||
['name' => 'alpha'],
|
||||
];
|
||||
|
||||
Pickles\Sort::by('name', $shuffled, Pickles\Sort::DESC);
|
||||
Sort::by('name', $shuffled, Sort::DESC);
|
||||
|
||||
$this->assertEquals($sorted, $shuffled);
|
||||
}
|
||||
|
@ -53,9 +57,8 @@ class SortTest extends PHPUnit_Framework_TestCase
|
|||
$shuffled = [['foo' => 'bar', 'bar' => 'foo']];
|
||||
$sorted = [['foo' => 'bar', 'bar' => 'foo']];
|
||||
|
||||
Pickles\Sort::by('name', $shuffled);
|
||||
Sort::by('name', $shuffled);
|
||||
|
||||
$this->assertEquals($sorted, $shuffled);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue