Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pelmered committed Jan 5, 2024
1 parent 2b6d06f commit 53b6726
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
13 changes: 13 additions & 0 deletions tests/FormInputTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace Pelmered\FilamentMoneyField\Tests;

use Pelmered\FilamentMoneyField\Infolists\Components\MoneyEntry;

class FormInputTest extends TestCase
{

public function testFormInputMoneyFormat(): void
{
$this->markTestSkipped('Not implemented yet');
}
}
18 changes: 8 additions & 10 deletions tests/MoneyEntryTest.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
<?php
namespace Pelmered\FilamentMoneyField\Tests;

use JetBrains\PhpStorm\NoReturn;
use Pelmered\FilamentMoneyField\Infolists\Components\MoneyEntry;

class MoneyEntryTest extends TestCase
{
public function testInfoListMoneyFormat()
public function testInfoListMoneyFormat(): void
{
$this->markTestSkipped('Not implemented yet');
$this->markTestSkipped('Not working yet');

$moneyEntry = (new MoneyEntry('name'))->currency('SEK')->locale('sv_SE');

$moneyEntry->initMoneyEntry();

//MoneyTest::callMethod($moneyEntry, 'setUp', []);
//$moneyEntry->__call('setUp', []);
self::callMethod($moneyEntry, 'setUp', []);

$state = 1000000;

dd($moneyEntry->formatState('1000000'));

$value = $moneyEntry->evaluate($moneyEntry->formatStateUsing, [
$value = $moneyEntry->evaluate(self::getProperty($moneyEntry, 'formatStateUsing'), [
'state' => $state,
]);

dd($value);
$this->assertEquals('10000,00 kr', $value);


$this->assertEquals('10000,00 kr', $moneyEntry->formatState('1000000'));
}

}
7 changes: 0 additions & 7 deletions tests/MoneyInputTest.php

This file was deleted.

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

use Pelmered\FilamentMoneyField\Infolists\Components\MoneyEntry;
use Pelmered\FilamentMoneyField\Tests\TestCase;

class TableColumnTest extends TestCase
{

public function testTableColumnMoneyFormat(): void
{
$this->markTestSkipped('Not implemented yet');
}
}
9 changes: 9 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ public static function callMethod($obj, $name, array $args) {
$class = new \ReflectionClass($obj);
return $class->getMethod($name)->invokeArgs($obj, $args);
}

public static function getProperty($object, $property)
{
$reflectedClass = new \ReflectionClass($object);
$reflection = $reflectedClass->getProperty($property);
$reflection->setAccessible(true);
return $reflection->getValue($object);
}

public static function replaceNonBreakingSpaces(string $string): string
{
return preg_replace('/\s/', "\xc2\xa0", $string);
Expand Down

0 comments on commit 53b6726

Please sign in to comment.