2010-06-24 09:40:05 +01:00
|
|
|
<?php
|
|
|
|
|
2011-01-15 13:29:43 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2011-01-15 13:29:43 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
namespace Symfony\Tests\Component\Validator\Mapping\Loader;
|
2010-06-24 09:40:05 +01:00
|
|
|
|
|
|
|
require_once __DIR__.'/../../Fixtures/FilesLoader.php';
|
|
|
|
require_once __DIR__.'/../../Fixtures/Entity.php';
|
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
|
|
|
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
2010-06-24 09:40:05 +01:00
|
|
|
|
|
|
|
class FilesLoaderTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
2010-06-24 10:24:08 +01:00
|
|
|
public function testCallsGetFileLoaderInstanceForeachPath()
|
|
|
|
{
|
|
|
|
$loader = $this->getFilesLoader($this->getFileLoader());
|
|
|
|
$this->assertEquals(4, $loader->getTimesCalled());
|
|
|
|
}
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
public function testCallsActualFileLoaderForMetadata()
|
|
|
|
{
|
|
|
|
$fileLoader = $this->getFileLoader();
|
|
|
|
$fileLoader->expects($this->exactly(4))
|
|
|
|
->method('loadClassMetadata');
|
|
|
|
$loader = $this->getFilesLoader($fileLoader);
|
2010-08-20 22:09:55 +01:00
|
|
|
$loader->loadClassMetadata(new ClassMetadata('Symfony\Tests\Component\Validator\Fixtures\Entity'));
|
2010-06-24 10:24:08 +01:00
|
|
|
}
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
public function getFilesLoader(LoaderInterface $loader)
|
|
|
|
{
|
2010-08-20 22:09:55 +01:00
|
|
|
return $this->getMockForAbstractClass('Symfony\Tests\Component\Validator\Fixtures\FilesLoader', array(array(
|
2010-06-24 10:24:08 +01:00
|
|
|
__DIR__ . '/constraint-mapping.xml',
|
|
|
|
__DIR__ . '/constraint-mapping.yaml',
|
|
|
|
__DIR__ . '/constraint-mapping.test',
|
|
|
|
__DIR__ . '/constraint-mapping.txt',
|
|
|
|
), $loader));
|
|
|
|
}
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
public function getFileLoader()
|
|
|
|
{
|
2010-08-20 22:09:55 +01:00
|
|
|
return $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
|
2010-06-24 10:24:08 +01:00
|
|
|
}
|
2011-06-08 18:56:59 +01:00
|
|
|
}
|