Skip to content

Commit

Permalink
Merge pull request laravel-doctrine#631 from TomHAnderson/feature/tes…
Browse files Browse the repository at this point in the history
…t-assets

Feature/test assets
  • Loading branch information
TomHAnderson authored Oct 26, 2024
2 parents 630a494 + 5e71eb5 commit b7a0d76
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace LaravelDoctrineTest\ORM\Entity;
namespace LaravelDoctrineTest\ORM\Assets\Entity;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: "App\Doctrine\ORM\Repository\ScientistRepository")]
#[ORM\Entity(repositoryClass: "LaravelDoctrineTest\ORM\Assets\Repository\ScientistRepository")]
class Scientist
{
#[ORM\Id]
Expand Down
4 changes: 2 additions & 2 deletions tests/Entity/Theory.php → tests/Assets/Entity/Theory.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace LaravelDoctrineTest\ORM\Entity;
namespace LaravelDoctrineTest\ORM\Assets\Entity;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: "App\Doctrine\ORM\Repository\TheoryRepository")]
#[ORM\Entity(repositoryClass: "LaravelDoctrineTest\ORM\Assets\Repository\TheoryRepository")]
class Theory
{
#[ORM\Id]
Expand Down
9 changes: 9 additions & 0 deletions tests/Assets/Repository/ScientistRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Repository;

use Doctrine\ORM\EntityRepository;

class ScientistRepository extends EntityRepository
{
}
9 changes: 9 additions & 0 deletions tests/Assets/Repository/TheoryRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace LaravelDoctrineTest\ORM\Assets\Repository;

use Doctrine\ORM\EntityRepository;

class TheoryRepository extends EntityRepository
{
}
19 changes: 9 additions & 10 deletions tests/Feature/IlluminateRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Exception\ORMException;
use Illuminate\Contracts\Container\Container;
use LaravelDoctrine\ORM\EntityManagerFactory;
use LaravelDoctrine\ORM\IlluminateRegistry;
Expand Down Expand Up @@ -423,14 +422,14 @@ public function testGetManagerForClass(): void

$metadataFactory = m::mock(\Doctrine\ORM\Mapping\ClassMetadataFactory::class);
$metadataFactory->shouldReceive('isTransient')
->with('LaravelDoctrineTest\ORM\Entity\Scientist')
->with('LaravelDoctrineTest\ORM\Assets\Entity\Scientist')
->once()
->andReturnFalse();

$metadata = m::mock(\Doctrine\Persistence\Mapping\ClassMetadata::class);
$metadata->shouldReceive('getName')
->once()
->andReturn('LaravelDoctrineTest\ORM\Entity\Scientist');
->andReturn('LaravelDoctrineTest\ORM\Assets\Entity\Scientist');

$metadataFactory->shouldReceive('getAllMetadata')
->once()
Expand All @@ -439,7 +438,7 @@ public function testGetManagerForClass(): void
$entityManager->shouldReceive('getMetadataFactory')
->andReturn($metadataFactory);

$this->assertEquals($entityManager, $this->registry->getManagerForClass('LaravelDoctrineTest\ORM\Entity\Scientist'));
$this->assertEquals($entityManager, $this->registry->getManagerForClass('LaravelDoctrineTest\ORM\Assets\Entity\Scientist'));
}

public function testGetManagerForClassWithNamespace(): void
Expand All @@ -457,21 +456,21 @@ public function testGetManagerForClassWithNamespace(): void
$configuration->shouldReceive('getEntityNamespace')
->with('Alias')
->once()
->andReturn('LaravelDoctrineTest\ORM\Entity');
->andReturn('LaravelDoctrineTest\ORM\Assets\Entity');

$entityManager->shouldReceive('getConfiguration')->andReturn($configuration);


$metadataFactory = m::mock(\Doctrine\ORM\Mapping\ClassMetadataFactory::class);
$metadataFactory->shouldReceive('isTransient')
->with('LaravelDoctrineTest\ORM\Entity\Scientist')
->with('LaravelDoctrineTest\ORM\Assets\Entity\Scientist')
->once()
->andReturnFalse();

$metadata = m::mock(\Doctrine\Persistence\Mapping\ClassMetadata::class);
$metadata->shouldReceive('getName')
->once()
->andReturn('LaravelDoctrineTest\ORM\Entity\Scientist');
->andReturn('LaravelDoctrineTest\ORM\Assets\Entity\Scientist');

$metadataFactory->shouldReceive('getAllMetadata')
->once()
Expand All @@ -497,14 +496,14 @@ public function testGetManagerForClassThrowsExceptionWhenNotFound(): void

$metadataFactory = m::mock(\Doctrine\ORM\Mapping\ClassMetadataFactory::class);
$metadataFactory->shouldReceive('isTransient')
->with('LaravelDoctrineTest\ORM\Entity\Scientist')
->with('LaravelDoctrineTest\ORM\Assets\Entity\Scientist')
->once()
->andReturnFalse();

$metadata = m::mock(\Doctrine\Persistence\Mapping\ClassMetadata::class);
$metadata->shouldReceive('getName')
->once()
->andReturn('LaravelDoctrineTest\ORM\Entity\Theory');
->andReturn('LaravelDoctrineTest\ORM\Assets\Entity\Theory');

$metadataFactory->shouldReceive('getAllMetadata')
->once()
Expand All @@ -513,7 +512,7 @@ public function testGetManagerForClassThrowsExceptionWhenNotFound(): void
$entityManager->shouldReceive('getMetadataFactory')
->andReturn($metadataFactory);

$this->assertEquals($entityManager, $this->registry->getManagerForClass('LaravelDoctrineTest\ORM\Entity\Scientist'));
$this->assertEquals($entityManager, $this->registry->getManagerForClass('LaravelDoctrineTest\ORM\Assets\Entity\Scientist'));
}

public function testGetManagerForClassInvalidClass(): void
Expand Down

0 comments on commit b7a0d76

Please sign in to comment.