Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CalculateActionTest #27

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions tests/Component/Action/CalculateActionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace Tests\Misery\Component\Action;

use Misery\Component\Action\CalculateAction;
use PHPUnit\Framework\TestCase;

class CalculateActionTest extends TestCase
{
public function test_it_should_retain_action_with_keys(): void
{
$format = new CalculateAction();

$item = [
'brand' => 'louis',
'description' => 'LV',
'sku' => '1',
];

$format->setOptions([
'keys' => ['brand', 'description'],
]);

$this->assertEquals([
'brand' => 'louis',
'description' => 'LV',
], $format->apply($item));
}

public function test_it_should_not_retain_action_with_keys(): void
{
$format = new RetainAction();

$item = [
'brand' => 'louis',
'description' => 'LV',
'sku' => '1',
];

$format->setOptions([
'keys' => [],
]);

$this->assertEquals([
'brand' => 'louis',
'description' => 'LV',
'sku' => '1',
], $format->apply($item));
}


public function test_it_should_do_a_retain_action_with_bad_keys(): void
{
$format = new RetainAction();

$item = [
'brand' => 'louis',
'description' => 'LV',
'sku' => '1',
0 => [false],
];

$format->setOptions([
'keys' => ['brand', 'description', 0, false, true, '', -1, 'the-unknown'],
]);

$this->assertEquals([
'brand' => 'louis',
'description' => 'LV',
0 => [false],
], $format->apply($item));
}
}