Skip to content
Permalink
Browse files

Make BehaviorRegistry::className() return null on failure.

  • Loading branch information...
ADmad committed Dec 5, 2017
1 parent 5e8cdc5 commit d4fc3321b800832e520d395995e257a9641bde9a
Showing with 5 additions and 3 deletions.
  1. +3 −3 src/ORM/BehaviorRegistry.php
  2. +2 −0 tests/TestCase/ORM/BehaviorRegistryTest.php
@@ -85,7 +85,7 @@ public function setTable(Table $table)
* Resolve a behavior classname.
*
* @param string $class Partial classname to resolve.
* @return string|false Either the correct classname or false.
* @return string|null Either the correct classname or null.
* @since 3.5.7
*/
public static function className($class)
@@ -95,7 +95,7 @@ public static function className($class)
$result = App::className($class, 'ORM/Behavior', 'Behavior');
}
return $result;
return $result ?: null;
}
/**
@@ -108,7 +108,7 @@ public static function className($class)
*/
protected function _resolveClassName($class)
{
return static::className($class);
return static::className($class) ?: false;
}
/**
@@ -67,6 +67,8 @@ public function testClassName()
$expected = 'TestPlugin\Model\Behavior\PersisterOneBehavior';
$result = BehaviorRegistry::className('TestPlugin.PersisterOne');
$this->assertSame($expected, $result);
$this->assertNull(BehaviorRegistry::className('NonExistent'));
}
/**

0 comments on commit d4fc332

Please sign in to comment.
You can’t perform that action at this time.