Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace yiiunit\framework\base; use yii\base\DynamicModel; use yii\base\Model; us..

Decoded Output download

<?php
 namespace yiiunitrameworkase; use yiiase\DynamicModel; use yiiase\Model; use yiiunit\dataase\InvalidRulesModel; use yiiunit\dataase\RulesModel; use yiiunit\dataase\Singer; use yiiunit\dataase\Speaker; use yiiunit\TestCase; class ModelTest extends TestCase { protected function setUp() : void { parent::setUp(); $this->mockApplication(); } public function testGetAttributeLabel() { $speaker = new Speaker(); $this->assertEquals("First Name", $speaker->getAttributeLabel("firstName")); $this->assertEquals("This is the custom label", $speaker->getAttributeLabel("customLabel")); $this->assertEquals("Underscore Style", $speaker->getAttributeLabel("underscore_style")); } public function testGetAttributes() { $speaker = new Speaker(); $speaker->firstName = "Qiang"; $speaker->lastName = "Xue"; $this->assertEquals(array("firstName" => "Qiang", "lastName" => "Xue", "customLabel" => null, "underscore_style" => null), $speaker->getAttributes()); $this->assertEquals(array("firstName" => "Qiang", "lastName" => "Xue"), $speaker->getAttributes(array("firstName", "lastName"))); $this->assertEquals(array("firstName" => "Qiang", "lastName" => "Xue"), $speaker->getAttributes(null, array("customLabel", "underscore_style"))); $this->assertEquals(array("firstName" => "Qiang"), $speaker->getAttributes(array("firstName", "lastName"), array("lastName", "customLabel", "underscore_style"))); } public function testSetAttributes() { $speaker = new Speaker(); $speaker->setAttributes(array("firstName" => "Qiang", "underscore_style" => "test")); $this->assertNull($speaker->firstName); $this->assertNull($speaker->underscore_style); $speaker = new Speaker(); $speaker->setScenario("test"); $speaker->setAttributes(array("firstName" => "Qiang", "underscore_style" => "test")); $this->assertNull($speaker->underscore_style); $this->assertEquals("Qiang", $speaker->firstName); $speaker->setAttributes(array("firstName" => "Qiang", "underscore_style" => "test"), false); $this->assertEquals("test", $speaker->underscore_style); $this->assertEquals("Qiang", $speaker->firstName); } public function testLoad() { $singer = new Singer(); $this->assertEquals("Singer", $singer->formName()); $post = array("firstName" => "Qiang"); Speaker::$formName = ''; $model = new Speaker(); $model->setScenario("test"); $this->assertTrue($model->load($post)); $this->assertEquals("Qiang", $model->firstName); Speaker::$formName = "Speaker"; $model = new Speaker(); $model->setScenario("test"); $this->assertTrue($model->load(array("Speaker" => $post))); $this->assertEquals("Qiang", $model->firstName); Speaker::$formName = "Speaker"; $model = new Speaker(); $model->setScenario("test"); $this->assertFalse($model->load(array("Example" => array()))); $this->assertEquals('', $model->firstName); } public function testLoadMultiple() { $data = array(array("firstName" => "Thomas", "lastName" => "Anderson"), array("firstName" => "Agent", "lastName" => "Smith")); Speaker::$formName = ''; $neo = new Speaker(); $neo->setScenario("test"); $smith = new Speaker(); $smith->setScenario("test"); $this->assertTrue(Speaker::loadMultiple(array($neo, $smith), $data)); $this->assertEquals("Thomas", $neo->firstName); $this->assertEquals("Smith", $smith->lastName); Speaker::$formName = "Speaker"; $neo = new Speaker(); $neo->setScenario("test"); $smith = new Speaker(); $smith->setScenario("test"); $this->assertTrue(Speaker::loadMultiple(array($neo, $smith), array("Speaker" => $data), "Speaker")); $this->assertEquals("Thomas", $neo->firstName); $this->assertEquals("Smith", $smith->lastName); Speaker::$formName = "Speaker"; $neo = new Speaker(); $neo->setScenario("test"); $smith = new Speaker(); $smith->setScenario("test"); $this->assertFalse(Speaker::loadMultiple(array($neo, $smith), array("Speaker" => $data), "Morpheus")); $this->assertEquals('', $neo->firstName); $this->assertEquals('', $smith->lastName); } public function testActiveAttributes() { $speaker = new Speaker(); $this->assertEmpty($speaker->activeAttributes()); $speaker = new Speaker(); $speaker->setScenario("test"); $this->assertEquals(array("firstName", "lastName", "underscore_style"), $speaker->activeAttributes()); } public function testActiveAttributesAreUnique() { $speaker = new Speaker(); $this->assertEmpty($speaker->activeAttributes()); $speaker = new Speaker(); $speaker->setScenario("duplicates"); $this->assertEquals(array("firstName", "underscore_style"), $speaker->activeAttributes()); } public function testIsAttributeSafe() { $speaker = new Speaker(); $this->assertFalse($speaker->isAttributeSafe("firstName")); $speaker = new Speaker(); $speaker->setScenario("test"); $this->assertTrue($speaker->isAttributeSafe("firstName")); } public function testIsAttributeSafeForIntegerAttribute() { $model = new RulesModel(); $model->rules = array(array(array(123456), "safe")); $this->assertTrue($model->isAttributeSafe(123456)); } public function testSafeScenarios() { $model = new RulesModel(); $model->rules = array(array(array("account_id", "user_id"), "required")); $model->scenario = Model::SCENARIO_DEFAULT; $this->assertEquals(array("account_id", "user_id"), $model->safeAttributes()); $this->assertEquals(array("account_id", "user_id"), $model->activeAttributes()); $model->scenario = "update"; $this->assertEquals(array(), $model->safeAttributes()); $this->assertEquals(array(), $model->activeAttributes()); $model = new RulesModel(); $model->rules = array(array(array("account_id", "user_id"), "required"), array(array("user_id"), "number", "on" => array("create", "update")), array(array("email", "name"), "required", "on" => "create")); $model->scenario = Model::SCENARIO_DEFAULT; $this->assertEquals(array("account_id", "user_id"), $model->safeAttributes()); $this->assertEquals(array("account_id", "user_id"), $model->activeAttributes()); $model->scenario = "update"; $this->assertEquals(array("account_id", "user_id"), $model->safeAttributes()); $this->assertEquals(array("account_id", "user_id"), $model->activeAttributes()); $model->scenario = "create"; $this->assertEquals(array("account_id", "user_id", "email", "name"), $model->safeAttributes()); $this->assertEquals(array("account_id", "user_id", "email", "name"), $model->activeAttributes()); $model = new RulesModel(); $model->rules = array(array(array("account_id", "user_id"), "required"), array(array("user_id"), "number", "on" => array("create", "update")), array(array("email", "name"), "required", "on" => "create"), array(array("email", "name"), "required", "on" => "update")); $model->scenario = Model::SCENARIO_DEFAULT; $this->assertEquals(array("account_id", "user_id"), $model->safeAttributes()); $this->assertEquals(array("account_id", "user_id"), $model->activeAttributes()); $model->scenario = "update"; $this->assertEquals(array("account_id", "user_id", "email", "name"), $model->safeAttributes()); $this->assertEquals(array("account_id", "user_id", "email", "name"), $model->activeAttributes()); $model->scenario = "create"; $this->assertEquals(array("account_id", "user_id", "email", "name"), $model->safeAttributes()); $this->assertEquals(array("account_id", "user_id", "email", "name"), $model->activeAttributes()); } public function testUnsafeAttributes() { $model = new RulesModel(); $model->rules = array(array(array("name", "!email"), "required")); $this->assertEquals(array("name"), $model->safeAttributes()); $this->assertEquals(array("name", "email"), $model->activeAttributes()); $model->attributes = array("name" => "mdmunir", "email" => "[email protected]"); $this->assertNull($model->email); $this->assertFalse($model->validate()); $model = new RulesModel(); $model->rules = array(array(array("name"), "required"), array(array("!user_id"), "default", "value" => "3426")); $model->attributes = array("name" => "mdmunir", "user_id" => "62792684"); $this->assertTrue($model->validate()); $this->assertEquals("3426", $model->user_id); $model = new RulesModel(); $model->rules = array(array(array("name", "email"), "required"), array(array("!email"), "safe")); $this->assertEquals(array("name"), $model->safeAttributes()); $model->attributes = array("name" => "mdmunir", "email" => "[email protected]"); $this->assertFalse($model->validate()); $model = new RulesModel(); $model->rules = array(array(array("name", "email"), "required"), array(array("email"), "email"), array(array("!email"), "safe", "on" => "update")); $model->setScenario(RulesModel::SCENARIO_DEFAULT); $this->assertEquals(array("name", "email"), $model->safeAttributes()); $model->attributes = array("name" => "mdmunir", "email" => "[email protected]"); $this->assertTrue($model->validate()); $model->setScenario("update"); $this->assertEquals(array("name"), $model->safeAttributes()); $model->attributes = array("name" => "D426", "email" => "[email protected]"); $this->assertNotEquals("[email protected]", $model->email); } public function testErrors() { $speaker = new Speaker(); $this->assertEmpty($speaker->getErrors()); $this->assertEmpty($speaker->getErrors("firstName")); $this->assertEmpty($speaker->getFirstErrors()); $this->assertFalse($speaker->hasErrors()); $this->assertFalse($speaker->hasErrors("firstName")); $speaker->addError("firstName", "Something is wrong!"); $this->assertEquals(array("firstName" => array("Something is wrong!")), $speaker->getErrors()); $this->assertEquals(array("Something is wrong!"), $speaker->getErrors("firstName")); $speaker->addError("firstName", "Totally wrong!"); $this->assertEquals(array("firstName" => array("Something is wrong!", "Totally wrong!")), $speaker->getErrors()); $this->assertEquals(array("Something is wrong!", "Totally wrong!"), $speaker->getErrors("firstName")); $this->assertTrue($speaker->hasErrors()); $this->assertTrue($speaker->hasErrors("firstName")); $this->assertFalse($speaker->hasErrors("lastName")); $this->assertEquals(array("firstName" => "Something is wrong!"), $speaker->getFirstErrors()); $this->assertEquals("Something is wrong!", $speaker->getFirstError("firstName")); $this->assertNull($speaker->getFirstError("lastName")); $speaker->addError("lastName", "Another one!"); $this->assertEquals(array("firstName" => array("Something is wrong!", "Totally wrong!"), "lastName" => array("Another one!")), $speaker->getErrors()); $this->assertEquals(array("Something is wrong!", "Totally wrong!", "Another one!"), $speaker->getErrorSummary(true)); $this->assertEquals(array("Something is wrong!", "Another one!"), $speaker->getErrorSummary(false)); $speaker->clearErrors("firstName"); $this->assertEquals(array("lastName" => array("Another one!")), $speaker->getErrors()); $speaker->clearErrors(); $this->assertEmpty($speaker->getErrors()); $this->assertFalse($speaker->hasErrors()); } public function testAddErrors() { $singer = new Singer(); $errors = array("firstName" => array("Something is wrong!")); $singer->addErrors($errors); $this->assertEquals($singer->getErrors(), $errors); $singer->clearErrors(); $singer->addErrors(array("firstName" => "Something is wrong!")); $this->assertEquals($singer->getErrors(), array("firstName" => array("Something is wrong!"))); $singer->clearErrors(); $errors = array("firstName" => array("Something is wrong!", "Totally wrong!")); $singer->addErrors($errors); $this->assertEquals($singer->getErrors(), $errors); $singer->clearErrors(); $errors = array("firstName" => array("Something is wrong!"), "lastName" => array("Another one!")); $singer->addErrors($errors); $this->assertEquals($singer->getErrors(), $errors); $singer->clearErrors(); $errors = array("firstName" => array("Something is wrong!", "Totally wrong!"), "lastName" => array("Another one!")); $singer->addErrors($errors); $this->assertEquals($singer->getErrors(), $errors); $singer->clearErrors(); $errors = array("firstName" => array("Something is wrong!", "Totally wrong!"), "lastName" => array("Another one!", "Totally wrong!")); $singer->addErrors($errors); $this->assertEquals($singer->getErrors(), $errors); } public function testArraySyntax() { $speaker = new Speaker(); $this->assertNull($speaker["firstName"]); $this->assertFalse(isset($speaker["firstName"])); $this->assertFalse(isset($speaker["unExistingField"])); $speaker["firstName"] = "Qiang"; $this->assertEquals("Qiang", $speaker["firstName"]); $this->assertTrue(isset($speaker["firstName"])); $attributes = array(); foreach ($speaker as $key => $attribute) { $attributes[$key] = $attribute; } $this->assertEquals(array("firstName" => "Qiang", "lastName" => null, "customLabel" => null, "underscore_style" => null), $attributes); unset($speaker["firstName"]); $this->assertNull($speaker["firstName"]); $this->assertFalse(isset($speaker["firstName"])); } public function testDefaults() { $singer = new Model(); $this->assertEquals(array(), $singer->rules()); $this->assertEquals(array(), $singer->attributeLabels()); } public function testDefaultScenarios() { $singer = new Singer(); $this->assertEquals(array("default" => array("lastName", "underscore_style", "test")), $singer->scenarios()); $scenarios = array("default" => array("id", "name", "description"), "administration" => array("name", "description", "is_disabled")); $model = new ComplexModel1(); $this->assertEquals($scenarios, $model->scenarios()); $scenarios = array("default" => array("id", "name", "description"), "suddenlyUnexpectedScenario" => array("name", "description"), "administration" => array("id", "name", "description", "is_disabled")); $model = new ComplexModel2(); $this->assertEquals($scenarios, $model->scenarios()); } public function testValidatorsWithDifferentScenarios() { $model = new CustomScenariosModel(); self::assertCount(3, $model->getActiveValidators()); self::assertCount(2, $model->getActiveValidators("name")); $model->setScenario("secondScenario"); self::assertCount(2, $model->getActiveValidators()); self::assertCount(2, $model->getActiveValidators("id")); self::assertCount(0, $model->getActiveValidators("name"), "This attribute has no validators in current scenario."); } public function testIsAttributeRequired() { $singer = new Singer(); $this->assertFalse($singer->isAttributeRequired("firstName")); $this->assertTrue($singer->isAttributeRequired("lastName")); $singer->firstName = "qiang"; $this->assertFalse($singer->isAttributeRequired("test")); $singer->firstName = "cebe"; $this->assertFalse($singer->isAttributeRequired("test")); } public function testCreateValidators() { $this->expectException("yiiase\InvalidConfigException"); $this->expectExceptionMessage("Invalid validation rule: a rule must specify both attribute names and validator type."); $invalid = new InvalidRulesModel(); $invalid->createValidators(); } public function testValidateWriteOnly() { $model = new WriteOnlyModel(); $model->setAttributes(array("password" => "test"), true); $this->assertEquals("test", $model->passwordHash); $this->assertTrue($model->validate()); } public function testValidateAttributeNames() { $model = new ComplexModel1(); $model->name = "Some value"; $this->assertTrue($model->validate(array("name")), "Should validate only name attribute"); $this->assertTrue($model->validate("name"), "Should validate only name attribute"); $this->assertFalse($model->validate(), "Should validate all attributes"); } public function testFormNameWithAnonymousClass() { $model = (require __DIR__ . "/stub/AnonymousModelClass.php"); $this->expectException("yiiase\InvalidConfigException"); $this->expectExceptionMessage("The "formName()" method should be explicitly defined for anonymous models"); $model->formName(); } public function testExcludeEmptyAttributesFromSafe() { $model = new DynamicModel(array('' => "emptyFieldValue")); $model->addRule('', "safe"); $this->assertEquals(array(), $model->safeAttributes()); $this->assertEquals(array(''), $model->attributes()); } } class ComplexModel1 extends Model { public $name; public $description; public $id; public $is_disabled; public function rules() { return array(array(array("id"), "required", "except" => "administration"), array(array("name", "description"), "filter", "filter" => "trim", "skipOnEmpty" => true), array(array("is_disabled"), "boolean", "on" => "administration")); } } class ComplexModel2 extends Model { public function rules() { return array(array(array("id"), "required", "except" => "suddenlyUnexpectedScenario"), array(array("name", "description"), "filter", "filter" => "trim"), array(array("is_disabled"), "boolean", "on" => "administration")); } } class WriteOnlyModel extends Model { public $passwordHash; public function rules() { return array(array(array("password"), "safe")); } public function setPassword($pw) { $this->passwordHash = $pw; } } class CustomScenariosModel extends Model { public $id; public $name; public function rules() { return array(array(array("id", "name"), "required"), array("id", "integer"), array("name", "string")); } public function scenarios() { return array(self::SCENARIO_DEFAULT => array("id", "name"), "secondScenario" => array("id")); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace yiiunit\framework\base; use yii\base\DynamicModel; use yii\base\Model; use yiiunit\data\base\InvalidRulesModel; use yiiunit\data\base\RulesModel; use yiiunit\data\base\Singer; use yiiunit\data\base\Speaker; use yiiunit\TestCase; class ModelTest extends TestCase { protected function setUp() : void { parent::setUp(); $this->mockApplication(); } public function testGetAttributeLabel() { $speaker = new Speaker(); $this->assertEquals("\x46\151\x72\163\x74\40\116\x61\155\145", $speaker->getAttributeLabel("\146\151\162\163\x74\x4e\141\155\x65")); $this->assertEquals("\x54\150\151\x73\x20\151\x73\40\x74\150\x65\40\143\x75\163\x74\x6f\155\x20\154\141\142\x65\x6c", $speaker->getAttributeLabel("\143\165\163\164\x6f\155\114\141\142\x65\154")); $this->assertEquals("\x55\x6e\144\x65\162\163\143\157\162\x65\x20\x53\164\171\x6c\145", $speaker->getAttributeLabel("\165\x6e\x64\145\162\163\143\x6f\x72\145\x5f\x73\x74\x79\x6c\145")); } public function testGetAttributes() { $speaker = new Speaker(); $speaker->firstName = "\121\151\x61\x6e\x67"; $speaker->lastName = "\x58\165\145"; $this->assertEquals(array("\146\151\162\x73\x74\116\141\x6d\x65" => "\121\x69\141\156\147", "\154\x61\x73\164\116\x61\x6d\x65" => "\130\165\145", "\143\165\163\164\x6f\155\114\141\142\145\x6c" => null, "\x75\x6e\x64\x65\x72\x73\x63\x6f\x72\x65\x5f\x73\x74\171\154\x65" => null), $speaker->getAttributes()); $this->assertEquals(array("\146\x69\x72\x73\164\x4e\141\x6d\145" => "\121\151\141\x6e\147", "\x6c\141\163\164\116\141\x6d\145" => "\x58\165\145"), $speaker->getAttributes(array("\146\x69\x72\163\x74\x4e\x61\155\145", "\154\141\x73\164\x4e\141\x6d\x65"))); $this->assertEquals(array("\x66\151\162\x73\x74\x4e\141\155\x65" => "\x51\151\x61\156\147", "\x6c\x61\163\164\x4e\141\155\x65" => "\x58\x75\x65"), $speaker->getAttributes(null, array("\x63\165\x73\164\x6f\155\114\x61\x62\x65\154", "\x75\x6e\144\145\x72\163\x63\x6f\x72\x65\137\x73\x74\171\x6c\145"))); $this->assertEquals(array("\x66\151\162\x73\x74\116\x61\155\x65" => "\121\x69\141\x6e\x67"), $speaker->getAttributes(array("\x66\x69\162\163\164\116\141\x6d\x65", "\x6c\x61\163\164\116\x61\155\145"), array("\154\141\163\164\x4e\x61\x6d\x65", "\143\x75\163\164\157\x6d\114\141\x62\145\154", "\165\x6e\144\145\x72\163\x63\157\162\145\x5f\163\164\171\x6c\x65"))); } public function testSetAttributes() { $speaker = new Speaker(); $speaker->setAttributes(array("\146\151\162\163\164\x4e\x61\x6d\145" => "\x51\151\x61\x6e\147", "\165\156\144\x65\x72\163\x63\x6f\162\145\137\163\164\x79\154\145" => "\164\x65\x73\x74")); $this->assertNull($speaker->firstName); $this->assertNull($speaker->underscore_style); $speaker = new Speaker(); $speaker->setScenario("\x74\x65\163\164"); $speaker->setAttributes(array("\x66\151\162\x73\164\116\141\155\145" => "\x51\x69\x61\156\x67", "\165\x6e\x64\145\x72\x73\x63\x6f\162\145\x5f\x73\x74\171\x6c\x65" => "\x74\145\x73\164")); $this->assertNull($speaker->underscore_style); $this->assertEquals("\x51\x69\141\156\x67", $speaker->firstName); $speaker->setAttributes(array("\146\x69\x72\163\164\116\x61\x6d\145" => "\121\151\x61\x6e\x67", "\x75\x6e\x64\145\162\x73\x63\157\x72\145\137\x73\x74\x79\x6c\x65" => "\x74\145\163\x74"), false); $this->assertEquals("\x74\x65\163\x74", $speaker->underscore_style); $this->assertEquals("\x51\151\141\156\x67", $speaker->firstName); } public function testLoad() { $singer = new Singer(); $this->assertEquals("\123\151\x6e\x67\x65\x72", $singer->formName()); $post = array("\146\151\162\163\x74\116\x61\155\145" => "\x51\x69\x61\x6e\147"); Speaker::$formName = ''; $model = new Speaker(); $model->setScenario("\x74\x65\163\x74"); $this->assertTrue($model->load($post)); $this->assertEquals("\x51\x69\141\x6e\x67", $model->firstName); Speaker::$formName = "\x53\160\145\141\x6b\x65\x72"; $model = new Speaker(); $model->setScenario("\x74\145\163\x74"); $this->assertTrue($model->load(array("\x53\160\x65\141\153\145\x72" => $post))); $this->assertEquals("\121\151\141\156\x67", $model->firstName); Speaker::$formName = "\x53\160\145\141\153\145\162"; $model = new Speaker(); $model->setScenario("\164\145\163\x74"); $this->assertFalse($model->load(array("\105\170\x61\x6d\160\x6c\x65" => array()))); $this->assertEquals('', $model->firstName); } public function testLoadMultiple() { $data = array(array("\x66\151\x72\163\164\116\x61\155\x65" => "\x54\150\x6f\155\141\x73", "\154\x61\163\x74\x4e\141\155\145" => "\x41\x6e\144\145\162\163\157\x6e"), array("\146\151\162\x73\x74\x4e\141\x6d\145" => "\101\147\145\156\x74", "\x6c\141\163\x74\116\141\x6d\x65" => "\x53\155\x69\164\150")); Speaker::$formName = ''; $neo = new Speaker(); $neo->setScenario("\x74\145\x73\x74"); $smith = new Speaker(); $smith->setScenario("\164\x65\163\164"); $this->assertTrue(Speaker::loadMultiple(array($neo, $smith), $data)); $this->assertEquals("\x54\x68\x6f\155\x61\163", $neo->firstName); $this->assertEquals("\123\x6d\151\x74\x68", $smith->lastName); Speaker::$formName = "\123\160\x65\x61\153\145\162"; $neo = new Speaker(); $neo->setScenario("\x74\145\163\164"); $smith = new Speaker(); $smith->setScenario("\x74\x65\163\x74"); $this->assertTrue(Speaker::loadMultiple(array($neo, $smith), array("\x53\x70\145\x61\x6b\145\162" => $data), "\x53\160\x65\x61\153\x65\162")); $this->assertEquals("\124\x68\157\x6d\x61\x73", $neo->firstName); $this->assertEquals("\123\x6d\x69\x74\150", $smith->lastName); Speaker::$formName = "\123\160\x65\141\x6b\x65\x72"; $neo = new Speaker(); $neo->setScenario("\x74\x65\163\164"); $smith = new Speaker(); $smith->setScenario("\164\x65\163\164"); $this->assertFalse(Speaker::loadMultiple(array($neo, $smith), array("\x53\160\145\141\x6b\145\x72" => $data), "\115\157\x72\160\x68\x65\x75\163")); $this->assertEquals('', $neo->firstName); $this->assertEquals('', $smith->lastName); } public function testActiveAttributes() { $speaker = new Speaker(); $this->assertEmpty($speaker->activeAttributes()); $speaker = new Speaker(); $speaker->setScenario("\x74\x65\x73\x74"); $this->assertEquals(array("\146\x69\x72\163\164\116\x61\155\x65", "\154\141\163\x74\116\x61\155\145", "\x75\156\144\145\162\163\143\157\x72\x65\137\163\164\x79\154\145"), $speaker->activeAttributes()); } public function testActiveAttributesAreUnique() { $speaker = new Speaker(); $this->assertEmpty($speaker->activeAttributes()); $speaker = new Speaker(); $speaker->setScenario("\144\165\x70\154\151\x63\141\164\x65\x73"); $this->assertEquals(array("\146\151\162\x73\164\116\x61\x6d\145", "\x75\x6e\x64\145\162\x73\x63\x6f\162\x65\x5f\163\164\171\154\x65"), $speaker->activeAttributes()); } public function testIsAttributeSafe() { $speaker = new Speaker(); $this->assertFalse($speaker->isAttributeSafe("\x66\151\162\x73\x74\116\141\x6d\x65")); $speaker = new Speaker(); $speaker->setScenario("\x74\145\x73\164"); $this->assertTrue($speaker->isAttributeSafe("\x66\x69\162\163\x74\116\x61\155\145")); } public function testIsAttributeSafeForIntegerAttribute() { $model = new RulesModel(); $model->rules = array(array(array(123456), "\163\141\146\145")); $this->assertTrue($model->isAttributeSafe(123456)); } public function testSafeScenarios() { $model = new RulesModel(); $model->rules = array(array(array("\x61\x63\x63\157\x75\x6e\x74\x5f\151\x64", "\165\x73\145\x72\x5f\x69\x64"), "\162\x65\x71\165\x69\162\x65\144")); $model->scenario = Model::SCENARIO_DEFAULT; $this->assertEquals(array("\x61\143\x63\157\165\156\x74\x5f\x69\144", "\165\x73\145\x72\137\x69\144"), $model->safeAttributes()); $this->assertEquals(array("\141\x63\x63\157\x75\x6e\x74\x5f\151\x64", "\x75\163\145\x72\x5f\151\x64"), $model->activeAttributes()); $model->scenario = "\x75\x70\x64\141\164\145"; $this->assertEquals(array(), $model->safeAttributes()); $this->assertEquals(array(), $model->activeAttributes()); $model = new RulesModel(); $model->rules = array(array(array("\141\x63\143\x6f\165\156\x74\137\151\x64", "\165\x73\x65\x72\137\x69\x64"), "\x72\145\x71\165\x69\162\145\144"), array(array("\165\x73\145\162\137\151\x64"), "\x6e\x75\155\x62\x65\162", "\x6f\156" => array("\143\x72\145\x61\164\145", "\x75\160\144\141\x74\x65")), array(array("\x65\x6d\141\151\x6c", "\156\141\155\x65"), "\162\145\x71\165\x69\x72\x65\x64", "\157\x6e" => "\143\x72\x65\141\164\145")); $model->scenario = Model::SCENARIO_DEFAULT; $this->assertEquals(array("\x61\143\x63\157\165\156\x74\137\x69\x64", "\165\163\x65\x72\x5f\151\144"), $model->safeAttributes()); $this->assertEquals(array("\141\143\143\x6f\x75\x6e\x74\137\x69\x64", "\165\163\x65\162\x5f\x69\144"), $model->activeAttributes()); $model->scenario = "\x75\160\144\x61\x74\145"; $this->assertEquals(array("\x61\x63\143\157\165\156\164\x5f\x69\x64", "\x75\163\x65\162\137\151\144"), $model->safeAttributes()); $this->assertEquals(array("\141\x63\x63\157\165\x6e\164\x5f\151\144", "\165\163\145\x72\137\151\144"), $model->activeAttributes()); $model->scenario = "\143\162\145\141\x74\145"; $this->assertEquals(array("\x61\x63\143\x6f\x75\x6e\164\137\x69\x64", "\x75\163\x65\162\x5f\151\x64", "\145\x6d\141\151\154", "\x6e\x61\155\145"), $model->safeAttributes()); $this->assertEquals(array("\141\143\143\x6f\165\156\x74\137\151\x64", "\x75\x73\145\x72\x5f\151\144", "\145\155\x61\151\154", "\156\x61\155\145"), $model->activeAttributes()); $model = new RulesModel(); $model->rules = array(array(array("\141\x63\x63\x6f\165\156\164\x5f\151\144", "\165\x73\145\x72\x5f\151\144"), "\162\145\161\165\151\162\x65\144"), array(array("\165\x73\145\x72\x5f\x69\144"), "\x6e\165\155\x62\145\x72", "\157\156" => array("\143\162\145\141\x74\x65", "\x75\160\144\141\164\145")), array(array("\x65\155\141\x69\154", "\x6e\x61\x6d\145"), "\x72\145\x71\165\151\x72\145\x64", "\x6f\x6e" => "\x63\162\x65\141\164\x65"), array(array("\x65\x6d\141\x69\154", "\x6e\141\x6d\x65"), "\162\x65\x71\165\151\x72\x65\x64", "\x6f\x6e" => "\x75\x70\144\x61\164\x65")); $model->scenario = Model::SCENARIO_DEFAULT; $this->assertEquals(array("\x61\x63\x63\157\x75\156\164\x5f\x69\x64", "\x75\x73\145\162\137\x69\144"), $model->safeAttributes()); $this->assertEquals(array("\141\x63\143\x6f\165\156\x74\137\x69\144", "\165\x73\145\162\x5f\151\x64"), $model->activeAttributes()); $model->scenario = "\x75\x70\x64\141\164\145"; $this->assertEquals(array("\141\143\143\157\165\x6e\164\x5f\x69\x64", "\165\x73\x65\x72\137\x69\144", "\x65\155\141\x69\154", "\x6e\141\x6d\x65"), $model->safeAttributes()); $this->assertEquals(array("\141\x63\x63\x6f\165\x6e\164\137\151\144", "\x75\163\145\162\x5f\x69\144", "\x65\x6d\141\151\154", "\x6e\x61\x6d\145"), $model->activeAttributes()); $model->scenario = "\143\162\145\141\x74\145"; $this->assertEquals(array("\x61\143\x63\x6f\165\x6e\x74\x5f\151\x64", "\165\163\145\x72\x5f\x69\144", "\145\155\x61\151\154", "\x6e\141\x6d\x65"), $model->safeAttributes()); $this->assertEquals(array("\141\143\143\x6f\x75\x6e\164\137\151\144", "\x75\163\145\x72\137\151\144", "\x65\155\141\x69\x6c", "\x6e\x61\x6d\145"), $model->activeAttributes()); } public function testUnsafeAttributes() { $model = new RulesModel(); $model->rules = array(array(array("\156\141\155\x65", "\x21\x65\x6d\x61\151\154"), "\x72\x65\161\165\x69\x72\145\144")); $this->assertEquals(array("\156\141\155\x65"), $model->safeAttributes()); $this->assertEquals(array("\x6e\141\x6d\145", "\145\x6d\x61\x69\x6c"), $model->activeAttributes()); $model->attributes = array("\156\x61\155\x65" => "\x6d\144\x6d\165\156\x69\x72", "\145\155\x61\x69\154" => "\x6d\x64\x6d\100\x6d\165\156\56\x63\157\155"); $this->assertNull($model->email); $this->assertFalse($model->validate()); $model = new RulesModel(); $model->rules = array(array(array("\x6e\x61\155\x65"), "\x72\x65\x71\165\151\162\x65\x64"), array(array("\x21\165\163\145\x72\137\151\144"), "\x64\145\x66\141\165\154\x74", "\166\x61\x6c\x75\x65" => "\x33\x34\x32\x36")); $model->attributes = array("\156\x61\x6d\x65" => "\x6d\x64\x6d\x75\156\x69\x72", "\x75\163\x65\162\x5f\x69\144" => "\x36\x32\67\71\62\x36\x38\x34"); $this->assertTrue($model->validate()); $this->assertEquals("\x33\64\x32\x36", $model->user_id); $model = new RulesModel(); $model->rules = array(array(array("\156\x61\x6d\x65", "\x65\155\141\151\x6c"), "\x72\x65\161\x75\x69\162\145\x64"), array(array("\41\145\155\x61\x69\154"), "\x73\x61\x66\x65")); $this->assertEquals(array("\x6e\x61\x6d\x65"), $model->safeAttributes()); $model->attributes = array("\156\141\x6d\x65" => "\155\x64\x6d\165\156\x69\162", "\x65\155\x61\151\x6c" => "\x6d\x32\67\x39\x32\x36\70\x34\100\155\x64\x6d\56\143\157\x6d"); $this->assertFalse($model->validate()); $model = new RulesModel(); $model->rules = array(array(array("\x6e\141\x6d\145", "\x65\155\141\151\154"), "\x72\x65\x71\x75\151\x72\145\x64"), array(array("\145\155\x61\x69\x6c"), "\x65\155\x61\151\x6c"), array(array("\x21\145\x6d\x61\151\x6c"), "\x73\x61\x66\x65", "\x6f\156" => "\x75\160\x64\141\x74\145")); $model->setScenario(RulesModel::SCENARIO_DEFAULT); $this->assertEquals(array("\x6e\141\x6d\145", "\145\x6d\x61\151\154"), $model->safeAttributes()); $model->attributes = array("\156\x61\x6d\145" => "\x6d\x64\155\165\156\151\162", "\145\155\x61\151\154" => "\155\x32\x37\71\62\66\x38\64\100\155\144\155\x2e\x63\x6f\x6d"); $this->assertTrue($model->validate()); $model->setScenario("\x75\x70\x64\x61\164\145"); $this->assertEquals(array("\156\x61\x6d\x65"), $model->safeAttributes()); $model->attributes = array("\156\141\x6d\x65" => "\x44\64\x32\x36", "\145\155\x61\x69\x6c" => "\144\64\x32\66\x40\155\144\x6d\x2e\x63\157\x6d"); $this->assertNotEquals("\x64\64\62\66\x40\x6d\144\x6d\56\x63\x6f\155", $model->email); } public function testErrors() { $speaker = new Speaker(); $this->assertEmpty($speaker->getErrors()); $this->assertEmpty($speaker->getErrors("\x66\x69\162\x73\x74\x4e\141\155\145")); $this->assertEmpty($speaker->getFirstErrors()); $this->assertFalse($speaker->hasErrors()); $this->assertFalse($speaker->hasErrors("\146\151\x72\x73\164\x4e\x61\155\145")); $speaker->addError("\146\x69\162\163\x74\x4e\141\x6d\x65", "\x53\157\155\x65\164\150\x69\156\x67\x20\x69\x73\40\167\x72\157\156\x67\x21"); $this->assertEquals(array("\x66\151\x72\163\164\x4e\x61\x6d\145" => array("\123\157\x6d\145\164\150\151\x6e\x67\40\x69\x73\x20\x77\162\157\156\147\41")), $speaker->getErrors()); $this->assertEquals(array("\x53\x6f\x6d\x65\x74\x68\x69\x6e\147\x20\151\x73\x20\167\x72\x6f\x6e\147\41"), $speaker->getErrors("\x66\x69\162\163\x74\116\x61\155\x65")); $speaker->addError("\146\151\x72\163\x74\116\141\x6d\145", "\124\x6f\x74\141\x6c\154\x79\40\x77\x72\157\x6e\147\41"); $this->assertEquals(array("\x66\151\162\x73\x74\116\x61\155\145" => array("\123\157\x6d\145\x74\150\151\x6e\147\x20\151\x73\40\x77\x72\157\156\147\41", "\x54\157\x74\141\x6c\154\x79\x20\167\x72\x6f\156\147\41")), $speaker->getErrors()); $this->assertEquals(array("\123\x6f\x6d\x65\164\150\151\156\147\x20\151\x73\x20\167\x72\157\156\147\41", "\124\157\164\x61\x6c\x6c\171\40\x77\x72\x6f\156\147\41"), $speaker->getErrors("\x66\151\x72\163\x74\116\141\155\145")); $this->assertTrue($speaker->hasErrors()); $this->assertTrue($speaker->hasErrors("\146\151\x72\x73\x74\116\x61\155\145")); $this->assertFalse($speaker->hasErrors("\x6c\x61\x73\x74\116\x61\155\x65")); $this->assertEquals(array("\x66\x69\x72\163\164\116\x61\x6d\x65" => "\123\x6f\155\x65\x74\150\151\156\147\x20\x69\163\40\x77\162\157\156\x67\x21"), $speaker->getFirstErrors()); $this->assertEquals("\123\x6f\x6d\145\x74\150\x69\156\147\x20\151\163\40\x77\x72\157\x6e\147\41", $speaker->getFirstError("\146\x69\x72\163\164\116\x61\155\145")); $this->assertNull($speaker->getFirstError("\154\141\163\164\x4e\141\x6d\x65")); $speaker->addError("\x6c\x61\163\x74\x4e\141\155\x65", "\101\156\157\164\x68\x65\x72\x20\157\x6e\x65\x21"); $this->assertEquals(array("\x66\x69\x72\x73\x74\x4e\141\155\145" => array("\x53\x6f\x6d\x65\164\x68\x69\156\147\x20\151\x73\40\x77\162\157\x6e\147\x21", "\x54\157\x74\x61\x6c\154\x79\40\167\162\157\156\x67\x21"), "\154\141\x73\164\x4e\141\155\x65" => array("\101\x6e\x6f\164\150\145\x72\40\x6f\x6e\145\41")), $speaker->getErrors()); $this->assertEquals(array("\x53\x6f\155\145\x74\150\x69\x6e\147\x20\x69\x73\x20\167\x72\x6f\156\x67\x21", "\124\157\x74\x61\x6c\x6c\x79\40\167\x72\157\156\147\x21", "\101\x6e\157\x74\150\x65\162\x20\157\156\x65\41"), $speaker->getErrorSummary(true)); $this->assertEquals(array("\123\157\x6d\x65\164\150\151\156\x67\x20\151\x73\x20\167\162\x6f\x6e\147\x21", "\101\x6e\x6f\x74\x68\145\x72\40\x6f\x6e\145\41"), $speaker->getErrorSummary(false)); $speaker->clearErrors("\x66\x69\x72\163\164\x4e\141\155\x65"); $this->assertEquals(array("\154\141\163\164\x4e\141\x6d\145" => array("\101\156\157\164\x68\145\x72\x20\x6f\156\145\x21")), $speaker->getErrors()); $speaker->clearErrors(); $this->assertEmpty($speaker->getErrors()); $this->assertFalse($speaker->hasErrors()); } public function testAddErrors() { $singer = new Singer(); $errors = array("\146\x69\162\163\x74\x4e\141\155\x65" => array("\123\x6f\x6d\145\164\x68\151\x6e\147\40\x69\x73\x20\167\162\157\x6e\x67\41")); $singer->addErrors($errors); $this->assertEquals($singer->getErrors(), $errors); $singer->clearErrors(); $singer->addErrors(array("\146\x69\162\x73\x74\116\141\155\145" => "\123\157\155\145\164\150\x69\x6e\x67\40\x69\163\40\x77\x72\157\156\147\41")); $this->assertEquals($singer->getErrors(), array("\146\x69\x72\x73\164\116\141\x6d\x65" => array("\123\157\x6d\145\x74\x68\151\x6e\x67\x20\x69\x73\40\x77\162\157\x6e\147\41"))); $singer->clearErrors(); $errors = array("\x66\x69\x72\163\x74\x4e\141\x6d\145" => array("\123\x6f\x6d\145\164\150\151\x6e\147\40\x69\163\x20\x77\x72\157\x6e\147\x21", "\x54\x6f\x74\x61\154\x6c\171\40\x77\x72\x6f\x6e\x67\41")); $singer->addErrors($errors); $this->assertEquals($singer->getErrors(), $errors); $singer->clearErrors(); $errors = array("\146\x69\x72\163\x74\116\141\155\x65" => array("\x53\x6f\x6d\x65\x74\150\x69\x6e\147\40\151\x73\x20\167\162\x6f\x6e\x67\x21"), "\x6c\141\163\x74\116\141\x6d\145" => array("\101\x6e\x6f\164\150\x65\162\x20\157\x6e\145\41")); $singer->addErrors($errors); $this->assertEquals($singer->getErrors(), $errors); $singer->clearErrors(); $errors = array("\x66\151\162\x73\x74\x4e\x61\155\x65" => array("\123\x6f\155\x65\164\x68\x69\156\147\40\x69\163\x20\x77\x72\157\156\147\x21", "\x54\157\164\x61\x6c\x6c\x79\40\167\x72\157\156\x67\x21"), "\154\141\163\164\116\141\155\145" => array("\101\x6e\x6f\x74\x68\145\x72\40\x6f\156\x65\41")); $singer->addErrors($errors); $this->assertEquals($singer->getErrors(), $errors); $singer->clearErrors(); $errors = array("\x66\x69\x72\x73\164\x4e\141\155\x65" => array("\x53\x6f\x6d\145\x74\150\151\x6e\x67\40\x69\163\x20\167\x72\157\x6e\x67\41", "\124\x6f\x74\141\x6c\x6c\x79\40\167\162\x6f\156\x67\x21"), "\154\x61\x73\164\x4e\141\x6d\145" => array("\101\x6e\157\x74\150\145\162\x20\157\x6e\145\x21", "\x54\x6f\164\141\154\154\171\40\x77\x72\x6f\156\147\41")); $singer->addErrors($errors); $this->assertEquals($singer->getErrors(), $errors); } public function testArraySyntax() { $speaker = new Speaker(); $this->assertNull($speaker["\x66\x69\x72\x73\x74\116\x61\155\x65"]); $this->assertFalse(isset($speaker["\146\151\x72\163\x74\x4e\x61\x6d\145"])); $this->assertFalse(isset($speaker["\x75\156\105\170\x69\x73\164\151\156\x67\106\x69\145\x6c\144"])); $speaker["\x66\151\x72\x73\164\116\141\155\145"] = "\121\151\x61\x6e\147"; $this->assertEquals("\x51\151\141\x6e\147", $speaker["\x66\151\x72\163\x74\116\141\155\145"]); $this->assertTrue(isset($speaker["\x66\x69\162\163\164\x4e\x61\x6d\x65"])); $attributes = array(); foreach ($speaker as $key => $attribute) { $attributes[$key] = $attribute; } $this->assertEquals(array("\x66\x69\162\163\164\116\141\x6d\x65" => "\x51\x69\141\x6e\x67", "\154\x61\x73\x74\116\141\x6d\x65" => null, "\143\165\x73\x74\157\155\114\x61\x62\145\154" => null, "\165\x6e\x64\145\x72\163\x63\x6f\162\x65\137\x73\x74\x79\x6c\145" => null), $attributes); unset($speaker["\146\x69\x72\163\164\x4e\141\155\145"]); $this->assertNull($speaker["\146\151\162\163\x74\116\141\155\x65"]); $this->assertFalse(isset($speaker["\146\151\162\163\x74\x4e\141\x6d\x65"])); } public function testDefaults() { $singer = new Model(); $this->assertEquals(array(), $singer->rules()); $this->assertEquals(array(), $singer->attributeLabels()); } public function testDefaultScenarios() { $singer = new Singer(); $this->assertEquals(array("\x64\x65\x66\x61\165\154\x74" => array("\x6c\141\x73\164\116\141\155\x65", "\165\156\144\145\162\163\143\x6f\x72\x65\137\x73\x74\x79\x6c\x65", "\164\x65\x73\164")), $singer->scenarios()); $scenarios = array("\x64\x65\x66\141\x75\x6c\164" => array("\151\144", "\156\x61\x6d\145", "\144\x65\163\143\162\x69\x70\164\x69\157\156"), "\141\144\155\x69\156\x69\x73\164\162\x61\x74\151\x6f\156" => array("\156\141\x6d\145", "\144\145\163\x63\162\x69\x70\164\151\157\x6e", "\151\x73\x5f\144\x69\x73\x61\x62\x6c\x65\144")); $model = new ComplexModel1(); $this->assertEquals($scenarios, $model->scenarios()); $scenarios = array("\144\145\x66\x61\165\154\164" => array("\151\144", "\156\141\155\x65", "\144\x65\x73\143\x72\x69\x70\164\x69\x6f\x6e"), "\163\x75\x64\x64\x65\156\x6c\x79\x55\156\145\x78\x70\145\143\x74\145\x64\x53\143\x65\x6e\x61\x72\151\x6f" => array("\x6e\141\x6d\x65", "\144\x65\x73\143\162\x69\x70\164\x69\x6f\156"), "\x61\x64\x6d\x69\x6e\151\x73\x74\x72\x61\164\151\x6f\156" => array("\x69\144", "\x6e\x61\x6d\145", "\x64\145\x73\143\x72\151\160\x74\x69\x6f\x6e", "\x69\x73\137\x64\x69\163\141\x62\x6c\x65\x64")); $model = new ComplexModel2(); $this->assertEquals($scenarios, $model->scenarios()); } public function testValidatorsWithDifferentScenarios() { $model = new CustomScenariosModel(); self::assertCount(3, $model->getActiveValidators()); self::assertCount(2, $model->getActiveValidators("\x6e\141\155\145")); $model->setScenario("\163\145\x63\157\x6e\x64\x53\143\145\156\x61\162\151\x6f"); self::assertCount(2, $model->getActiveValidators()); self::assertCount(2, $model->getActiveValidators("\151\x64")); self::assertCount(0, $model->getActiveValidators("\x6e\141\155\x65"), "\124\150\x69\163\40\x61\x74\x74\x72\x69\142\x75\x74\145\x20\150\x61\163\40\156\x6f\x20\166\141\x6c\x69\x64\141\x74\157\x72\x73\40\151\156\40\143\165\x72\162\145\156\164\x20\163\143\145\x6e\x61\x72\x69\x6f\x2e"); } public function testIsAttributeRequired() { $singer = new Singer(); $this->assertFalse($singer->isAttributeRequired("\146\x69\x72\x73\164\x4e\141\155\145")); $this->assertTrue($singer->isAttributeRequired("\154\141\x73\x74\x4e\141\155\145")); $singer->firstName = "\x71\151\141\x6e\147"; $this->assertFalse($singer->isAttributeRequired("\x74\145\163\x74")); $singer->firstName = "\143\145\x62\145"; $this->assertFalse($singer->isAttributeRequired("\x74\145\x73\164")); } public function testCreateValidators() { $this->expectException("\171\151\x69\x5c\x62\x61\x73\x65\134\x49\156\x76\141\x6c\x69\x64\103\157\x6e\146\x69\x67\105\170\x63\x65\160\164\x69\157\156"); $this->expectExceptionMessage("\111\x6e\166\x61\x6c\x69\x64\x20\166\x61\154\x69\x64\141\164\151\157\156\40\x72\x75\x6c\x65\x3a\x20\141\40\x72\x75\x6c\x65\40\x6d\165\163\164\40\x73\160\145\143\x69\146\171\40\142\157\164\150\40\141\x74\164\162\x69\142\x75\164\x65\40\x6e\141\155\x65\x73\40\141\x6e\x64\x20\x76\141\x6c\151\x64\x61\x74\157\162\x20\164\x79\x70\x65\56"); $invalid = new InvalidRulesModel(); $invalid->createValidators(); } public function testValidateWriteOnly() { $model = new WriteOnlyModel(); $model->setAttributes(array("\x70\x61\163\x73\x77\x6f\x72\144" => "\x74\145\x73\x74"), true); $this->assertEquals("\164\x65\163\164", $model->passwordHash); $this->assertTrue($model->validate()); } public function testValidateAttributeNames() { $model = new ComplexModel1(); $model->name = "\x53\x6f\x6d\145\40\x76\x61\154\x75\145"; $this->assertTrue($model->validate(array("\x6e\x61\155\x65")), "\123\x68\x6f\x75\x6c\144\x20\166\141\154\151\144\x61\x74\145\40\157\x6e\x6c\171\x20\156\x61\155\145\40\141\164\164\162\x69\142\x75\x74\x65"); $this->assertTrue($model->validate("\x6e\141\155\145"), "\x53\x68\157\165\154\144\x20\x76\141\x6c\x69\144\x61\164\145\40\x6f\156\x6c\171\x20\x6e\x61\155\x65\x20\141\x74\x74\162\151\142\x75\164\x65"); $this->assertFalse($model->validate(), "\123\150\157\x75\154\144\40\166\141\x6c\151\x64\141\164\145\x20\x61\154\x6c\x20\141\164\164\x72\x69\142\x75\164\x65\x73"); } public function testFormNameWithAnonymousClass() { $model = (require __DIR__ . "\x2f\x73\x74\x75\x62\57\101\156\x6f\156\x79\155\157\165\x73\115\x6f\x64\145\x6c\x43\x6c\141\x73\163\56\x70\150\160"); $this->expectException("\171\151\x69\134\142\x61\x73\145\x5c\111\x6e\x76\x61\154\x69\x64\103\x6f\156\146\151\x67\x45\170\143\145\160\164\x69\157\156"); $this->expectExceptionMessage("\x54\x68\x65\40\x22\146\x6f\162\155\x4e\x61\x6d\x65\x28\51\x22\x20\x6d\145\x74\150\x6f\144\40\x73\150\x6f\x75\154\x64\x20\142\145\40\145\170\160\x6c\x69\x63\x69\164\154\x79\x20\144\x65\x66\x69\x6e\x65\x64\x20\146\157\x72\x20\x61\156\x6f\156\171\155\x6f\165\163\x20\155\157\x64\x65\x6c\163"); $model->formName(); } public function testExcludeEmptyAttributesFromSafe() { $model = new DynamicModel(array('' => "\x65\155\160\x74\171\x46\151\x65\x6c\x64\126\x61\x6c\x75\x65")); $model->addRule('', "\163\x61\146\145"); $this->assertEquals(array(), $model->safeAttributes()); $this->assertEquals(array(''), $model->attributes()); } } class ComplexModel1 extends Model { public $name; public $description; public $id; public $is_disabled; public function rules() { return array(array(array("\151\x64"), "\x72\145\161\165\151\162\145\x64", "\145\x78\143\145\x70\x74" => "\141\x64\155\x69\x6e\151\x73\164\162\141\x74\x69\157\156"), array(array("\156\x61\155\145", "\x64\x65\163\x63\x72\151\160\x74\x69\157\x6e"), "\x66\x69\154\164\x65\162", "\146\151\154\164\145\162" => "\x74\162\x69\155", "\163\153\151\x70\x4f\156\105\x6d\x70\x74\171" => true), array(array("\151\x73\x5f\x64\151\163\x61\142\x6c\x65\x64"), "\x62\157\x6f\x6c\x65\141\x6e", "\x6f\156" => "\x61\x64\x6d\x69\x6e\x69\x73\164\162\x61\x74\x69\157\156")); } } class ComplexModel2 extends Model { public function rules() { return array(array(array("\x69\144"), "\162\x65\161\x75\x69\x72\x65\x64", "\145\170\x63\x65\160\164" => "\163\165\144\x64\x65\x6e\154\171\125\x6e\145\170\160\x65\143\164\x65\x64\123\x63\x65\x6e\x61\x72\x69\157"), array(array("\x6e\141\155\145", "\x64\x65\x73\143\x72\x69\160\164\151\x6f\156"), "\146\151\154\x74\145\x72", "\x66\x69\154\164\145\x72" => "\x74\x72\151\155"), array(array("\151\x73\x5f\x64\151\163\141\x62\154\145\x64"), "\x62\157\x6f\154\x65\x61\156", "\157\156" => "\x61\144\155\x69\x6e\151\163\x74\x72\x61\x74\x69\x6f\156")); } } class WriteOnlyModel extends Model { public $passwordHash; public function rules() { return array(array(array("\160\141\x73\x73\167\x6f\162\x64"), "\163\x61\x66\145")); } public function setPassword($pw) { $this->passwordHash = $pw; } } class CustomScenariosModel extends Model { public $id; public $name; public function rules() { return array(array(array("\x69\x64", "\x6e\x61\x6d\x65"), "\162\x65\161\165\x69\162\145\x64"), array("\151\144", "\151\156\x74\x65\x67\145\x72"), array("\156\141\155\145", "\163\x74\162\151\x6e\x67")); } public function scenarios() { return array(self::SCENARIO_DEFAULT => array("\x69\144", "\x6e\141\x6d\x65"), "\163\x65\x63\x6f\x6e\x64\x53\x63\x65\x6e\x61\162\x69\x6f" => array("\x69\144")); } }

Function Calls

None

Variables

None

Stats

MD5 8d7e325eec2bbc93400b92639a2197a2
Eval Count 0
Decode Time 91 ms