Skip to content

Commit

Permalink
Refactored tests
Browse files Browse the repository at this point in the history
  • Loading branch information
assertchris committed Feb 2, 2017
1 parent 0eb11cd commit cb2e170
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 78 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"license": "MIT",
"require": {
"php": "^7.0",
"pre/plugin": "^0.4.0"
"pre/plugin": "^0.5"
},
"autoload": {
"files": [
Expand Down
1 change: 0 additions & 1 deletion tests/Fixture/.gitignore

This file was deleted.

33 changes: 0 additions & 33 deletions tests/Fixture/Fixture.pre

This file was deleted.

43 changes: 0 additions & 43 deletions tests/MacroTest.php

This file was deleted.

13 changes: 13 additions & 0 deletions tests/SpecTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Pre\ParameterLoaders;

use Pre\Testing\Runner;

class SpecTest extends Runner
{
protected function path(): string
{
return __DIR__ . "/specs";
}
}
9 changes: 9 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

namespace Yay;

// let's use a namespace trick, to make non-colliding variables predictable.

function md5($value)
{
return $value;
}

putenv("PRE_BASE_DIR=" . __DIR__ . "/..");

require __DIR__ . "/../vendor/autoload.php";
83 changes: 83 additions & 0 deletions tests/specs/parameter-loaders.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
--DESCRIPTION--

Test parameter loader macros

--GIVEN--

class Fixture
{
public function typeHintedRegular(string $string = "typeHintedRegular")
{
return "working";
}

public function typeHintedEnhanced(stdClass $object = new stdClass())
{
return "working";
}

public function multipleRegular($one = "one", $two = 2.2, $three = true, $four = null)
{
return "working";
}

public function multipleEnhanced($one = ucwords("one"), $two = round(2.2))
{
return "working";
}

public function mixed($one, $two = 2.2, $three = round(3.3), $four = new stdClass)
{
return "working";
}
}

--EXPECT--

class Fixture
{
public function typeHintedRegular(string $string ="typeHintedRegular")
{
return "working";
}

public function typeHintedEnhanced(stdClass $object = null)
{
if (is_null($object)) {
$object = new stdClass();
}

return "working";
}

public function multipleRegular($one ="one", $two =2.2, $three =true, $four =null)
{
return "working";
}

public function multipleEnhanced($one = null, $two = null)
{
if (is_null($one)) {
$one = ucwords("one");
}

if (is_null($two)) {
$two = round(2.2);
}

return "working";
}

public function mixed($one, $two =2.2, $three = null, $four = null)
{
if (is_null($three)) {
$three = round(3.3);
}

if (is_null($four)) {
$four = new stdClass ;
}

return "working";
}
}

0 comments on commit cb2e170

Please sign in to comment.