Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
update transform and format adding er on the end
Browse files Browse the repository at this point in the history
  • Loading branch information
Mombuyish committed Mar 2, 2019
1 parent f60a278 commit 5011e2b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: php
php:
- 7.0
- 7.1
- 7.2

before_script:
- composer self-update
Expand Down
9 changes: 4 additions & 5 deletions src/Foundation/helpers.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

use Yish\Generators\Exceptions\ClassNotFoundException;
use Yish\Generators\Exceptions\MethodNotFoundException;
use Illuminate\Http\Request;

if (! function_exists('transform')) {
function transform($instance, $attributes)
if (! function_exists('transformer')) {
function transformer($instance, $attributes)
{
if (! class_exists($instance)) {
throw new ClassNotFoundException($instance);
Expand All @@ -15,8 +14,8 @@ function transform($instance, $attributes)
}
}

if (! function_exists('format')) {
function format(Request $request, $instance, $items)
if (! function_exists('formatter')) {
function formatter(Request $request, $instance, $items)
{
if (! class_exists($instance)) {
throw new ClassNotFoundException($instance);
Expand Down
22 changes: 11 additions & 11 deletions tests/FormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public function it_should_format_and_success()
],
];

$result = format(request(), InstanceSuccess::class, [
$result = formatter(request(), InstanceSuccess::class, [
1,
2,
3,
Expand All @@ -323,7 +323,7 @@ public function it_should_format_and_failed()
'errors' => null,
];

$result = format(request(), InstanceFailed::class, null);
$result = formatter(request(), InstanceFailed::class, null);

$this->assertEquals($expected, $result);
}
Expand All @@ -344,7 +344,7 @@ public function it_should_format_and_customize_message_success_by_helper()
'items' => [],
];

$result = format(request(), CustomSuccessMessage::class, []);
$result = formatter(request(), CustomSuccessMessage::class, []);

$this->assertEquals($expected, $result);
}
Expand All @@ -363,7 +363,7 @@ public function it_should_format_and_customize_code_success_by_helper()
'items' => [],
];

$result = format(request(), CustomSuccessCode::class, []);
$result = formatter(request(), CustomSuccessCode::class, []);

$this->assertEquals($expected, $result);
}
Expand All @@ -384,7 +384,7 @@ public function it_should_format_and_customize_all_success_by_helper()
'items' => [],
];

$result = format(request(), CustomSuccessAll::class, []);
$result = formatter(request(), CustomSuccessAll::class, []);

$this->assertEquals($expected, $result);
}
Expand All @@ -405,7 +405,7 @@ public function it_should_format_and_customize_message_failed_by_helper()
'errors' => [],
];

$result = format(request(), CustomFailedMessage::class, []);
$result = formatter(request(), CustomFailedMessage::class, []);

$this->assertEquals($expected, $result);
}
Expand All @@ -424,7 +424,7 @@ public function it_should_format_and_customize_code_failed_by_helper()
'errors' => [],
];

$result = format(request(), CustomFailedCode::class, []);
$result = formatter(request(), CustomFailedCode::class, []);

$this->assertEquals($expected, $result);
}
Expand All @@ -445,7 +445,7 @@ public function it_should_format_and_customize_all_failed_by_helper()
'errors' => [],
];

$result = format(request(), CustomFailedAll::class, []);
$result = formatter(request(), CustomFailedAll::class, []);

$this->assertEquals($expected, $result);
}
Expand All @@ -458,7 +458,7 @@ public function it_should_format_not_found_class_by_helper()
{
$this->expectException(\Yish\Generators\Exceptions\ClassNotFoundException::class);

format(request(), ABCD::class, []);
formatter(request(), ABCD::class, []);
}

/**
Expand All @@ -469,7 +469,7 @@ public function if_status_not_bool_got_exception()
{
$this->expectException(\Yish\Generators\Exceptions\InvalidArgumentException::class);

format(request(), ErrorStatus::class, []);
formatter(request(), ErrorStatus::class, []);
}

/**
Expand All @@ -490,7 +490,7 @@ public function if_status_no_given_will_be_false()
'errors' => [],
];

$result = format(request(), NoGivenStatus::class, []);
$result = formatter(request(), NoGivenStatus::class, []);

$this->assertEquals($expected, $result);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/TransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function it_should_transform_by_helper()
{
$expected = ['name' => 'yish'];

$result = transform(UserTransformer::class, [
$result = transformer(UserTransformer::class, [
'name' => 'yish',
'age' => 28
]);
Expand All @@ -46,6 +46,6 @@ public function it_should_not_found_class_by_helper()
{
$this->expectException(\Yish\Generators\Exceptions\ClassNotFoundException::class);

transform(ABCD::class, []);
transformer(ABCD::class, []);
}
}

0 comments on commit 5011e2b

Please sign in to comment.