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

Possible implementation for #62 and temporary workaround for #63 #64

Conversation

pierpaolocira
Copy link
Contributor

Possible implementation for #62 and temporary workaround for #63 (necessary for #62 unit tests)

triplepoint added a commit to triplepoint/php-units-of-measure that referenced this pull request Jan 16, 2017
…, this fix mocks out UnitOfMeasureInterface::isAliasOf() for the AbstractPhysicalQuantityTest unit test mock.
*/
public static function listAllUnits()
{
$return = array();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not mix styles, [] instead of array()

@@ -71,4 +71,23 @@ public function subtract(PhysicalQuantityInterface $quantity);
* @return boolean True if the quantities are the same, false if not.
*/
public function isEquivalentQuantity(PhysicalQuantityInterface $testQuantity);

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These both look like good additions.

$unexistingUnits = array('kg', 'l', 'definitelynoconflict_');

foreach ($someExistingUnits as $someExistingUnit) {
$this->assertTrue(Wonkicity::isUnitDefined($someExistingUnit));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do a comment in the assertion, so we can tell which test failed. As this is here, it'll just error with "true should be false" or something like that. If it were like this, you'll get more explanation when the test fails:

        foreach ($someExistingUnits as $someExistingUnit) {
            $this->assertTrue(Wonkicity::isUnitDefined($someExistingUnit), "$someExistingUnit is not defined");
        }
        foreach ($unexistingUnits as $unexistingUnit) {
            $this->assertFalse(Wonkicity::isUnitDefined($unexistingUnit), "$unexistingUnit is defined");
        }

$newUnit = $this->getTestUnitOfMeasureSafe('noconflict', ['definitelynoconflict_1', 'definitelynoconflict_2']);
Wonkicity::addUnit($newUnit);

$someExistingUnits = array('u', 'uvees', 'v', 'vorp', 'noconflict', 'definitelynoconflict_1', 'definitelynoconflict_2');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here and on 257, let's use [] instead of array().

Wonkicity::addUnit($newUnit);

$allUnits = Wonkicity::listAllUnits();
$expected = array(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, [] instead of array().

@triplepoint
Copy link
Member

In addition to the changes in the above review, once #65 is landed to address your #63, you should be able to back out the fix for #63 you have here in this PR.

@pierpaolocira
Copy link
Contributor Author

Hi,
my apologise for the delay.

Now everything should be ok, and tests pass.

I also manually put here the code of the #65 (I don't see it in the master) in order to allow tests to pass. I hope it's ok.

Thanks

@pierpaolocira
Copy link
Contributor Author

Hi, any news about?
Thanks... ;)

@triplepoint
Copy link
Member

Hello, and sorry for the long delay.

This looks good now, I'm ok with merging it.

Thanks again for your contribution.

@triplepoint triplepoint merged commit 6107236 into PhpUnitsOfMeasure:master Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants