Skip to content

Commit

Permalink
Merge pull request #2 from donatj/fix/test-stub-namespacing
Browse files Browse the repository at this point in the history
Namespace stubs
  • Loading branch information
donatj committed May 11, 2023
2 parents 097cbd5 + 5f19f98 commit 9e69a1d
Show file tree
Hide file tree
Showing 26 changed files with 63 additions and 63 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"autoload-dev": {
"psr-4": {
"": "stubs/",
"Stubs\\": "stubs/",
"Tests\\": "test/",
"Tests82\\": "test82/"
}
Expand Down
2 changes: 1 addition & 1 deletion stubs/Interfaces/BazAwareInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Interfaces;
namespace Stubs\Interfaces;

interface BazAwareInterface {

Expand Down
2 changes: 1 addition & 1 deletion stubs/Interfaces/FooAwareInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Interfaces;
namespace Stubs\Interfaces;

interface FooAwareInterface {

Expand Down
2 changes: 1 addition & 1 deletion stubs/Interfaces/GarplyIdAwareInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Interfaces;
namespace Stubs\Interfaces;

interface GarplyIdAwareInterface {

Expand Down
2 changes: 1 addition & 1 deletion stubs/Interfaces/GarplyMemberInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Interfaces;
namespace Stubs\Interfaces;

interface GarplyMemberInterface extends
GarplyIdAwareInterface,
Expand Down
2 changes: 1 addition & 1 deletion stubs/Interfaces/NullableIdAwareInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Interfaces;
namespace Stubs\Interfaces;

interface NullableIdAwareInterface {

Expand Down
2 changes: 1 addition & 1 deletion stubs/Interfaces/QuxIdAwareInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Interfaces;
namespace Stubs\Interfaces;

interface QuxIdAwareInterface {

Expand Down
6 changes: 3 additions & 3 deletions stubs/Objects/Person/BarPerson.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Objects\Person;
namespace Stubs\Objects\Person;

use Traits\BazAwareTrait;
use Traits\FooAwareTrait;
use Stubs\Traits\BazAwareTrait;
use Stubs\Traits\FooAwareTrait;

class BarPerson extends Decorator implements BarPersonInterface {

Expand Down
6 changes: 3 additions & 3 deletions stubs/Objects/Person/BarPersonInterface.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Objects\Person;
namespace Stubs\Objects\Person;

use Objects\Person\PersonAwarenessInterfaces\BazAwarePersonInterface;
use Objects\Person\PersonAwarenessInterfaces\FooAwarePersonInterface;
use Stubs\Objects\Person\PersonAwarenessInterfaces\BazAwarePersonInterface;
use Stubs\Objects\Person\PersonAwarenessInterfaces\FooAwarePersonInterface;

interface BarPersonInterface extends BazAwarePersonInterface, FooAwarePersonInterface {

Expand Down
2 changes: 1 addition & 1 deletion stubs/Objects/Person/Decorator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Objects\Person;
namespace Stubs\Objects\Person;

abstract class Decorator implements PersonInterface {

Expand Down
2 changes: 1 addition & 1 deletion stubs/Objects/Person/InvokablePersonFactory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Objects\Person;
namespace Stubs\Objects\Person;

class InvokablePersonFactory {

Expand Down
8 changes: 4 additions & 4 deletions stubs/Objects/Person/Person.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Objects\Person;
namespace Stubs\Objects\Person;

use Traits\GarplyIdAwareTrait;
use Traits\NullableIdAwareTrait;
use Traits\QuxIdAwareTrait;
use Stubs\Traits\GarplyIdAwareTrait;
use Stubs\Traits\NullableIdAwareTrait;
use Stubs\Traits\QuxIdAwareTrait;

class Person implements PersonInterface {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Objects\Person\PersonAwarenessInterfaces;
namespace Stubs\Objects\Person\PersonAwarenessInterfaces;

use Interfaces\BazAwareInterface;
use Objects\Person\PersonInterface;
use Stubs\Interfaces\BazAwareInterface;
use Stubs\Objects\Person\PersonInterface;

interface BazAwarePersonInterface extends PersonInterface, BazAwareInterface {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Objects\Person\PersonAwarenessInterfaces;
namespace Stubs\Objects\Person\PersonAwarenessInterfaces;

use Interfaces\FooAwareInterface;
use Objects\Person\PersonInterface;
use Stubs\Interfaces\FooAwareInterface;
use Stubs\Objects\Person\PersonInterface;

interface FooAwarePersonInterface extends FooAwareInterface, PersonInterface {

Expand Down
4 changes: 2 additions & 2 deletions stubs/Objects/Person/PersonInterface.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Objects\Person;
namespace Stubs\Objects\Person;

use Interfaces\GarplyMemberInterface;
use JsonSerializable;
use Stubs\Interfaces\GarplyMemberInterface;

interface PersonInterface extends GarplyMemberInterface, JsonSerializable {

Expand Down
2 changes: 1 addition & 1 deletion stubs/Traits/BazAwareTrait.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Traits;
namespace Stubs\Traits;

trait BazAwareTrait {

Expand Down
2 changes: 1 addition & 1 deletion stubs/Traits/FooAwareTrait.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Traits;
namespace Stubs\Traits;

trait FooAwareTrait {

Expand Down
2 changes: 1 addition & 1 deletion stubs/Traits/GarplyIdAwareTrait.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Traits;
namespace Stubs\Traits;

trait GarplyIdAwareTrait {

Expand Down
2 changes: 1 addition & 1 deletion stubs/Traits/NullableIdAwareTrait.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Traits;
namespace Stubs\Traits;

trait NullableIdAwareTrait {

Expand Down
2 changes: 1 addition & 1 deletion stubs/Traits/QuxIdAwareTrait.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Traits;
namespace Stubs\Traits;

trait QuxIdAwareTrait {

Expand Down
22 changes: 11 additions & 11 deletions test/DNFTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
use donatj\PhpDnfSolver\Types\BuiltInType;
use donatj\PhpDnfSolver\Types\OrClause;
use donatj\PhpDnfSolver\Types\UserDefinedType;
use Interfaces\BazAwareInterface;
use Interfaces\FooAwareInterface;
use Objects\Person\BarPerson;
use Objects\Person\BarPersonInterface;
use Objects\Person\InvokablePersonFactory;
use Objects\Person\PersonInterface;
use PHPUnit\Framework\TestCase;
use Stubs\Interfaces\BazAwareInterface;
use Stubs\Interfaces\FooAwareInterface;
use Stubs\Objects\Person\BarPerson;
use Stubs\Objects\Person\BarPersonInterface;
use Stubs\Objects\Person\InvokablePersonFactory;
use Stubs\Objects\Person\PersonInterface;

class DNFTest extends TestCase {

Expand Down Expand Up @@ -54,7 +54,7 @@ public function test_getFromReflectionType() : void {
return $this->getMockBuilder(BazAwareInterface::class)->getMock();
}))->getReturnType()
);
$this->assertSame('Interfaces\BazAwareInterface|null', $dnf->dnf());
$this->assertSame('Stubs\Interfaces\BazAwareInterface|null', $dnf->dnf());
$this->assertInstanceOf(OrClause::class, $dnf);
$dnfTypes = $dnf->getTypes();
$this->assertInstanceOf(UserDefinedType::class, $dnfTypes[0]->getTypes()[0]); // Gets jammed into an AND
Expand All @@ -68,15 +68,15 @@ public function test_getFromReflectionType() : void {
}))->getReturnType()
);
$this->assertInstanceOf(OrClause::class, $dnf);
$this->assertSame('Interfaces\FooAwareInterface|Interfaces\BazAwareInterface', $dnf->dnf());
$this->assertSame('Stubs\Interfaces\FooAwareInterface|Stubs\Interfaces\BazAwareInterface', $dnf->dnf());

$dnf = DNF::getFromReflectionType(
(new \ReflectionFunction(function () : FooAwareInterface&BazAwareInterface {
return $this->getMockBuilder(BarPersonInterface::class)->getMock();
}))->getReturnType()
);
$this->assertInstanceOf(AndClause::class, $dnf);
$this->assertSame('Interfaces\FooAwareInterface&Interfaces\BazAwareInterface', $dnf->dnf());
$this->assertSame('Stubs\Interfaces\FooAwareInterface&Stubs\Interfaces\BazAwareInterface', $dnf->dnf());
}

public function test_getFromReflectionType_exception() : void {
Expand Down Expand Up @@ -223,12 +223,12 @@ public function test_getFromReturnType() : void {
$foo = fn () : FooAwareInterface|BazAwareInterface => $this->getMockBuilder(FooAwareInterface::class)->getMock();
$rf = new \ReflectionFunction($foo);
$dnf = DNF::getFromReturnType($rf);
$this->assertSame('Interfaces\FooAwareInterface|Interfaces\BazAwareInterface', $dnf->dnf());
$this->assertSame('Stubs\Interfaces\FooAwareInterface|Stubs\Interfaces\BazAwareInterface', $dnf->dnf());

$foo = fn () : FooAwareInterface&BazAwareInterface => $this->getMockBuilder(FooAwareInterface::class)->getMock();
$rf = new \ReflectionFunction($foo);
$dnf = DNF::getFromReturnType($rf);
$this->assertSame('Interfaces\FooAwareInterface&Interfaces\BazAwareInterface', $dnf->dnf());
$this->assertSame('Stubs\Interfaces\FooAwareInterface&Stubs\Interfaces\BazAwareInterface', $dnf->dnf());
}

}
10 changes: 5 additions & 5 deletions test/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
use donatj\PhpDnfSolver\Types\CallableType;
use donatj\PhpDnfSolver\Types\OrClause;
use donatj\PhpDnfSolver\Types\UserDefinedType;
use Interfaces\BazAwareInterface;
use Interfaces\FooAwareInterface;
use Objects\Person\BarPersonInterface;
use Objects\Person\InvokablePersonFactory;
use Objects\Person\PersonInterface;
use PHPUnit\Framework\TestCase;
use Stubs\Interfaces\BazAwareInterface;
use Stubs\Interfaces\FooAwareInterface;
use Stubs\Objects\Person\BarPersonInterface;
use Stubs\Objects\Person\InvokablePersonFactory;
use Stubs\Objects\Person\PersonInterface;

class IntegrationTest extends TestCase {

Expand Down
6 changes: 3 additions & 3 deletions test/Types/AndClauseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use donatj\PhpDnfSolver\Types\AndClause;
use donatj\PhpDnfSolver\Types\BuiltInType;
use donatj\PhpDnfSolver\Types\UserDefinedType;
use Interfaces\BazAwareInterface;
use Interfaces\FooAwareInterface;
use PHPUnit\Framework\TestCase;
use Stubs\Interfaces\BazAwareInterface;
use Stubs\Interfaces\FooAwareInterface;

class AndClauseTest extends TestCase {

Expand All @@ -34,7 +34,7 @@ public function test_dnf() : void {
new UserDefinedType(FooAwareInterface::class),
);

$this->assertSame('Interfaces\BazAwareInterface&Interfaces\FooAwareInterface', $clause->dnf());
$this->assertSame('Stubs\Interfaces\BazAwareInterface&Stubs\Interfaces\FooAwareInterface', $clause->dnf());
}

}
8 changes: 4 additions & 4 deletions test/Types/OrClauseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
use donatj\PhpDnfSolver\Types\BuiltInType;
use donatj\PhpDnfSolver\Types\OrClause;
use donatj\PhpDnfSolver\Types\UserDefinedType;
use Interfaces\BazAwareInterface;
use Interfaces\FooAwareInterface;
use Objects\Person\BarPersonInterface;
use PHPUnit\Framework\TestCase;
use Stubs\Interfaces\BazAwareInterface;
use Stubs\Interfaces\FooAwareInterface;
use Stubs\Objects\Person\BarPersonInterface;

class OrClauseTest extends TestCase {

Expand Down Expand Up @@ -66,7 +66,7 @@ public function test_dnf() : void {
new UserDefinedType(FooAwareInterface::class),
);

$this->assertSame('Interfaces\BazAwareInterface|Interfaces\FooAwareInterface', $clause->dnf());
$this->assertSame('Stubs\Interfaces\BazAwareInterface|Stubs\Interfaces\FooAwareInterface', $clause->dnf());
}

}
4 changes: 2 additions & 2 deletions test/Types/UserDefinedTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use donatj\PhpDnfSolver\Exceptions\InvalidArgumentException;
use donatj\PhpDnfSolver\Types\UserDefinedType;
use Interfaces\BazAwareInterface;
use PHPUnit\Framework\TestCase;
use Traits\BazAwareTrait;
use Stubs\Interfaces\BazAwareInterface;
use Stubs\Traits\BazAwareTrait;

class UserDefinedTypeTest extends TestCase {

Expand Down
12 changes: 6 additions & 6 deletions test82/DNFTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use donatj\PhpDnfSolver\DNF;
use donatj\PhpDnfSolver\Types\OrClause;
use Interfaces\BazAwareInterface;
use Interfaces\FooAwareInterface;
use Objects\Person\BarPerson;
use Objects\Person\InvokablePersonFactory;
use PHPUnit\Framework\TestCase;
use Stubs\Interfaces\BazAwareInterface;
use Stubs\Interfaces\FooAwareInterface;
use Stubs\Objects\Person\BarPerson;
use Stubs\Objects\Person\InvokablePersonFactory;
use Tests\TypeHelperTrait;

class DNFTest extends TestCase {
Expand All @@ -23,10 +23,10 @@ public function test_getFromReflectionType() : void {
);
$this->assertInstanceOf(OrClause::class, $dnf);
$this->assertCount(3, $dnf);
$this->assertSame('(Interfaces\FooAwareInterface&Interfaces\BazAwareInterface)|int|null', $dnf->dnf());
$this->assertSame('(Stubs\Interfaces\FooAwareInterface&Stubs\Interfaces\BazAwareInterface)|int|null', $dnf->dnf());

$types = $dnf->getTypes();
$this->assertSame('Interfaces\FooAwareInterface&Interfaces\BazAwareInterface', $types[0]->dnf());
$this->assertSame('Stubs\Interfaces\FooAwareInterface&Stubs\Interfaces\BazAwareInterface', $types[0]->dnf());
$this->assertSame('int', $types[1]->dnf());
$this->assertSame('null', $types[2]->dnf());
}
Expand Down

0 comments on commit 9e69a1d

Please sign in to comment.