silverstripe-cms/tests/php/Controllers/CMSMainTest_ClassA.php

24 lines
582 B
PHP
Raw Normal View History

<?php
2017-08-09 04:53:38 +02:00
namespace SilverStripe\CMS\Tests\Controllers;
2017-08-09 03:25:12 +02:00
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\ValidationException;
2017-08-09 03:25:12 +02:00
class CMSMainTest_ClassA extends SiteTree implements TestOnly
{
2017-08-09 04:53:38 +02:00
private static $table_name = 'CMSMainTest_ClassA';
private static $allowed_children = [CMSMainTest_ClassB::class];
protected function onBeforeWrite()
{
parent::onBeforeWrite();
if ($this->ClassName !== self::class) {
throw new ValidationException("Class saved with incorrect ClassName");
}
}
}