mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-31 07:09:45 +02:00
Applied rector suggestions
This commit is contained in:
parent
4106bcef5f
commit
20f32c7f12
170 changed files with 808 additions and 761 deletions
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\Parts;
|
||||
|
||||
use App\Entity\Parts\InfoProviderReference;
|
||||
|
@ -46,9 +48,9 @@ class InfoProviderReferenceTest extends TestCase
|
|||
//The provider reference instance should return true for the providerCreated method
|
||||
$this->assertTrue($provider->isProviderCreated());
|
||||
//And the correct values for all other methods
|
||||
$this->assertEquals('test', $provider->getProviderKey());
|
||||
$this->assertEquals('id', $provider->getProviderId());
|
||||
$this->assertEquals('url', $provider->getProviderUrl());
|
||||
$this->assertSame('test', $provider->getProviderKey());
|
||||
$this->assertSame('id', $provider->getProviderId());
|
||||
$this->assertSame('url', $provider->getProviderUrl());
|
||||
$this->assertNotNull($provider->getLastUpdated());
|
||||
}
|
||||
|
||||
|
@ -60,9 +62,9 @@ class InfoProviderReferenceTest extends TestCase
|
|||
//The provider reference instance should return true for the providerCreated method
|
||||
$this->assertTrue($reference->isProviderCreated());
|
||||
//And the correct values for all other methods
|
||||
$this->assertEquals('test', $reference->getProviderKey());
|
||||
$this->assertEquals('id', $reference->getProviderId());
|
||||
$this->assertEquals('url', $reference->getProviderUrl());
|
||||
$this->assertSame('test', $reference->getProviderKey());
|
||||
$this->assertSame('id', $reference->getProviderId());
|
||||
$this->assertSame('url', $reference->getProviderUrl());
|
||||
$this->assertNotNull($reference->getLastUpdated());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\Parts;
|
||||
|
||||
use App\Entity\Parts\AssociationType;
|
||||
|
@ -34,7 +36,7 @@ class PartAssociationTest extends TestCase
|
|||
$assoc->setOtherType('Custom Type');
|
||||
|
||||
//If the type is not OTHER the translation key should be the same as the type
|
||||
$this->assertEquals($assoc->getType()->getTranslationKey(), $assoc->getTypeTranslationKey());
|
||||
$this->assertSame($assoc->getType()->getTranslationKey(), $assoc->getTypeTranslationKey());
|
||||
|
||||
//If the type is OTHER the translation key should be the other type
|
||||
$assoc->setType(AssociationType::OTHER);
|
||||
|
|
|
@ -55,15 +55,15 @@ class PartTest extends TestCase
|
|||
|
||||
//Without a set measurement unit the part must return an int
|
||||
$part->setMinAmount(1.345);
|
||||
$this->assertSame(1.0, $part->getMinAmount());
|
||||
$this->assertEqualsWithDelta(1.0, $part->getMinAmount(), PHP_FLOAT_EPSILON);
|
||||
|
||||
//If a non-int-based unit is assigned, a float is returned
|
||||
$part->setPartUnit($measurement_unit);
|
||||
$this->assertSame(1.345, $part->getMinAmount());
|
||||
$this->assertEqualsWithDelta(1.345, $part->getMinAmount(), PHP_FLOAT_EPSILON);
|
||||
|
||||
//If an int-based unit is assigned an int is returned
|
||||
$measurement_unit->setIsInteger(true);
|
||||
$this->assertSame(1.0, $part->getMinAmount());
|
||||
$this->assertEqualsWithDelta(1.0, $part->getMinAmount(), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
|
||||
public function testUseFloatAmount(): void
|
||||
|
@ -87,7 +87,7 @@ class PartTest extends TestCase
|
|||
$measurement_unit = new MeasurementUnit();
|
||||
$datetime = new DateTime();
|
||||
|
||||
$this->assertSame(0.0, $part->getAmountSum());
|
||||
$this->assertEqualsWithDelta(0.0, $part->getAmountSum(), PHP_FLOAT_EPSILON);
|
||||
|
||||
$part->addPartLot((new PartLot())->setAmount(3.141));
|
||||
$part->addPartLot((new PartLot())->setAmount(10.0));
|
||||
|
@ -98,15 +98,15 @@ class PartTest extends TestCase
|
|||
->setExpirationDate($datetime->setTimestamp(strtotime('now -1 hour')))
|
||||
);
|
||||
|
||||
$this->assertSame(13.0, $part->getAmountSum());
|
||||
$this->assertEqualsWithDelta(13.0, $part->getAmountSum(), PHP_FLOAT_EPSILON);
|
||||
|
||||
$part->setPartUnit($measurement_unit);
|
||||
$this->assertSame(13.141, $part->getAmountSum());
|
||||
$this->assertEqualsWithDelta(13.141, $part->getAmountSum(), PHP_FLOAT_EPSILON);
|
||||
|
||||
//1 billion part lot
|
||||
$part->addPartLot((new PartLot())->setAmount(1_000_000_000));
|
||||
$this->assertSame(1_000_000_013.141, $part->getAmountSum());
|
||||
$this->assertEqualsWithDelta(1_000_000_013.141, $part->getAmountSum(), PHP_FLOAT_EPSILON);
|
||||
$measurement_unit->setIsInteger(true);
|
||||
$this->assertSame(1_000_000_013.0, $part->getAmountSum());
|
||||
$this->assertEqualsWithDelta(1_000_000_013.0, $part->getAmountSum(), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue