-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Copyright 2024 (C) IDMarinas - All Rights Reserved | ||
* | ||
* Last modified by "IDMarinas" on 28/11/24, 19:52 | ||
* | ||
* @project IDMarinas Common Bundle | ||
* @see https://github.com/idmarinas/common-bundle | ||
* | ||
* @file IdTraitTest.php | ||
* @date 28/11/2024 | ||
* @time 19:52 | ||
* | ||
* @author Iván Diaz Marinas (IDMarinas) | ||
* @license BSD 3-Clause License | ||
* | ||
* @since 3.0.0 | ||
*/ | ||
|
||
namespace Idm\Bundle\Common\Tests\Traits\Entity; | ||
|
||
use Idm\Bundle\Common\Traits\Entity\IdTrait; | ||
use phpmock\phpunit\PHPMock; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class IdTraitTest extends TestCase | ||
{ | ||
use PHPMock; | ||
|
||
public function testIdTrait () | ||
{ | ||
$entity = new IdTraitCheck(); | ||
$entity->setId(1); | ||
|
||
$this->assertEquals(1, $entity->getId()); | ||
} | ||
} | ||
|
||
class IdTraitCheck | ||
{ | ||
use IdTrait; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Copyright 2024 (C) IDMarinas - All Rights Reserved | ||
* | ||
* Last modified by "IDMarinas" on 28/11/24, 19:52 | ||
* | ||
* @project IDMarinas Common Bundle | ||
* @see https://github.com/idmarinas/common-bundle | ||
* | ||
* @file UuidTraitTest.php | ||
* @date 28/11/2024 | ||
* @time 19:52 | ||
* | ||
* @author Iván Diaz Marinas (IDMarinas) | ||
* @license BSD 3-Clause License | ||
* | ||
* @since 3.0.0 | ||
*/ | ||
|
||
namespace Idm\Bundle\Common\Tests\Traits\Entity; | ||
|
||
use Idm\Bundle\Common\Traits\Entity\UuidTrait; | ||
use PHPUnit\Framework\TestCase; | ||
use Ramsey\Uuid\UuidFactory; | ||
|
||
class UuidTraitTest extends TestCase | ||
{ | ||
public function testUuid () | ||
{ | ||
$entity = new UuidTraitCheck(); | ||
|
||
$uuid = (new UuidFactory())->uuid4(); | ||
$entity->setUuid($uuid); | ||
|
||
$this->assertEquals($uuid, $entity->getUuid()); | ||
} | ||
} | ||
|
||
class UuidTraitCheck | ||
{ | ||
use UuidTrait; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/** | ||
* Copyright 2024 (C) IDMarinas - All Rights Reserved | ||
* | ||
* Last modified by "IDMarinas" on 28/11/24, 19:33 | ||
* | ||
* @project IDMarinas Common Bundle | ||
* @see https://github.com/idmarinas/common-bundle | ||
* | ||
* @file FakerTraitTest.php | ||
* @date 28/11/2024 | ||
* @time 19:33 | ||
* | ||
* @author Iván Diaz Marinas (IDMarinas) | ||
* @license BSD 3-Clause License | ||
* | ||
* @since 3.0.0 | ||
*/ | ||
|
||
namespace Idm\Bundle\Common\Tests\Traits\Tool; | ||
|
||
use Idm\Bundle\Common\Traits\Tool\FakerTrait; | ||
use LogicException; | ||
use phpmock\phpunit\PHPMock; | ||
use PHPUnit\Framework\TestCase; | ||
use ReflectionClass; | ||
|
||
class FakerTraitTest extends TestCase | ||
{ | ||
use PHPMock; | ||
|
||
public function testFakerNotInstalled () | ||
{ | ||
$this->expectException(LogicException::class); | ||
|
||
$namespace = (new ReflectionClass(FakerTrait::class))->getNamespaceName(); | ||
$mock = $this->getFunctionMock($namespace, 'class_exists'); | ||
$mock->expects($this->once())->willReturn(false); | ||
|
||
(new FakerCheck())->faker(); | ||
} | ||
} | ||
|
||
class FakerCheck | ||
{ | ||
use FakerTrait; | ||
} |