Skip to content

Commit

Permalink
#16096 - Add unit test to mock whole Phalcon's codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Sep 17, 2022
1 parent b2aa4e6 commit 27b6a8f
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/unit/MassMockCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <team@phalcon.io>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Phalcon\Test\Unit;

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use ReflectionClass;

class MassMockCest extends TestCase
{
public function testSegFaults(): void
{
$classes = array_filter(get_declared_classes(), function ($var) {
return preg_match('/^Phalcon/', $var) === 1;
});
sort($classes);

foreach ($classes as $class) {
$reflector = new ReflectionClass($class);
/**
* Final class could not be mocked.
*/
if ($reflector->isFinal()) {
continue;
}

printf($class . PHP_EOL);
ob_flush();
$mockBuilder = $this->getMockBuilder($class)->disableOriginalConstructor();
$this->assertInstanceOf(MockObject::class, $mockBuilder->getMock());
}
}
}

0 comments on commit 27b6a8f

Please sign in to comment.