Skip to content

Commit

Permalink
Merge pull request #1 from preprocess/refactor-for-new-plugin
Browse files Browse the repository at this point in the history
Refactor for new plugin
  • Loading branch information
assertchris authored Oct 28, 2017
2 parents 0d4b0b5 + c91551c commit 20947f8
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 33 deletions.
15 changes: 3 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,15 @@
"name": "pre/six",
"license": "MIT",
"require": {
"pre/plugin": "^0.7.3"
"pre/plugin": "^0.10.0"
},
"autoload": {
"files": [
"src/expanders.php"
]
"files": ["source/expanders.php"]
},
"require-dev": {
"phpunit/phpunit": "^5.0|^6.0"
},
"autoload-dev": {
"psr-4": {
"Pre\\Six\\": "tests"
}
},
"extra": {
"macros": [
"src/macros.yay"
]
"macros": ["source/macros.yay"]
}
}
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand Down
File renamed without changes.
File renamed without changes.
41 changes: 35 additions & 6 deletions tests/MacroTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
<?php

namespace Pre\Six;
use PHPUnit\Framework\TestCase;

use Pre\Plugin\Testing\Runner;

class MacroTest extends Runner
class MacroTest extends TestCase
{
protected function path(): string
/**
* @test
* @dataProvider specs
*/
public function can_transform_code($from, $expected)
{
Pre\Plugin\addMacro(__DIR__ . "/../source/macros.yay");

$actual = Pre\plugin\format(Pre\Plugin\parse($this->format($from)));
$this->assertEquals($this->format($expected), $actual);
}

private function format($code)
{
return __DIR__ . "/specs";
return "<?php\n\n" . trim($code) . "\n";
}

public static function specs()
{
$specs = [];

$files = [
__DIR__ . "/specs/six.spec",
];

foreach ($files as $file) {
$contents = file_get_contents($file);

foreach (explode("---", $contents) as $spec) {
array_push($specs, explode("~~~", $spec));
}
}

return $specs;
}
}
7 changes: 0 additions & 7 deletions tests/bootstrap.php

This file was deleted.

8 changes: 1 addition & 7 deletions tests/specs/six.spec
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
--DESCRIPTION--

Test six macros

--GIVEN--

¼ + ¾ +++ ½

$thisfoo()
Expand All @@ -24,7 +18,7 @@ $this→foo()

💩 InvalidArgumentException

--EXPECT--
~~~

(1/4) + (3/4) + (1/3) + (2/3) + (1/2)

Expand Down

0 comments on commit 20947f8

Please sign in to comment.