You are here

class StaticMethodLoaderTest in Plug 7

Hierarchy

  • class \Symfony\Component\Validator\Tests\Mapping\Loader\StaticMethodLoaderTest extends \Symfony\Component\Validator\Tests\Mapping\Loader\PHPUnit_Framework_TestCase

Expanded class hierarchy of StaticMethodLoaderTest

File

lib/Symfony/validator/Symfony/Component/Validator/Tests/Mapping/Loader/StaticMethodLoaderTest.php, line 18

Namespace

Symfony\Component\Validator\Tests\Mapping\Loader
View source
class StaticMethodLoaderTest extends \PHPUnit_Framework_TestCase {
  private $errorLevel;
  protected function setUp() {
    $this->errorLevel = error_reporting();
  }
  protected function tearDown() {
    error_reporting($this->errorLevel);
  }
  public function testLoadClassMetadataReturnsTrueIfSuccessful() {
    $loader = new StaticMethodLoader('loadMetadata');
    $metadata = new ClassMetadata(__NAMESPACE__ . '\\StaticLoaderEntity');
    $this
      ->assertTrue($loader
      ->loadClassMetadata($metadata));
  }
  public function testLoadClassMetadataReturnsFalseIfNotSuccessful() {
    $loader = new StaticMethodLoader('loadMetadata');
    $metadata = new ClassMetadata('\\stdClass');
    $this
      ->assertFalse($loader
      ->loadClassMetadata($metadata));
  }
  public function testLoadClassMetadata() {
    $loader = new StaticMethodLoader('loadMetadata');
    $metadata = new ClassMetadata(__NAMESPACE__ . '\\StaticLoaderEntity');
    $loader
      ->loadClassMetadata($metadata);
    $this
      ->assertEquals(StaticLoaderEntity::$invokedWith, $metadata);
  }
  public function testLoadClassMetadataDoesNotRepeatLoadWithParentClasses() {
    $loader = new StaticMethodLoader('loadMetadata');
    $metadata = new ClassMetadata(__NAMESPACE__ . '\\StaticLoaderDocument');
    $loader
      ->loadClassMetadata($metadata);
    $this
      ->assertCount(0, $metadata
      ->getConstraints());
    $loader = new StaticMethodLoader('loadMetadata');
    $metadata = new ClassMetadata(__NAMESPACE__ . '\\BaseStaticLoaderDocument');
    $loader
      ->loadClassMetadata($metadata);
    $this
      ->assertCount(1, $metadata
      ->getConstraints());
  }
  public function testLoadClassMetadataIgnoresInterfaces() {
    $loader = new StaticMethodLoader('loadMetadata');
    $metadata = new ClassMetadata(__NAMESPACE__ . '\\StaticLoaderInterface');
    $loader
      ->loadClassMetadata($metadata);
    $this
      ->assertCount(0, $metadata
      ->getConstraints());
  }
  public function testLoadClassMetadataInAbstractClasses() {
    $loader = new StaticMethodLoader('loadMetadata');
    $metadata = new ClassMetadata(__NAMESPACE__ . '\\AbstractStaticLoader');
    $loader
      ->loadClassMetadata($metadata);
    $this
      ->assertCount(1, $metadata
      ->getConstraints());
  }
  public function testLoadClassMetadataIgnoresAbstractMethods() {

    // Disable error reporting, as AbstractStaticMethodLoader produces a
    // strict standards error
    error_reporting(0);
    if (0 !== error_reporting()) {
      $this
        ->markTestSkipped('Could not disable error reporting');
    }
    $metadata = new ClassMetadata(__NAMESPACE__ . '\\AbstractStaticMethodLoader');
    $loader = new StaticMethodLoader('loadMetadata');
    $loader
      ->loadClassMetadata($metadata);
    $this
      ->assertCount(0, $metadata
      ->getConstraints());
  }

}

Members