/** * Setup * * @return void */ public function setUp() { parent::setUp(); $this->type = Type::build('encryptedsecurity'); $this->driver = $this->getMockBuilder('Cake\\Database\\Driver')->getMock(); $this->crypted = base64_encode(Security::encrypt('string', Configure::read('Security.key'))); }
/** * Setup * * @return void */ public function setUp() { parent::setUp(); Type::map('binary', BinaryType::class); $this->type = Type::build('binary'); $this->driver = $this->getMockBuilder(Driver::class)->getMock(); }
/** * Setup * * @return void */ public function setUp() { parent::setUp(); $this->type = Type::build('datetime'); $this->driver = $this->getMock('Cake\\Database\\Driver'); $this->_originalMap = Type::map(); }
public function beforeFilter(Event $event) { parent::beforeFilter($event); $session = $this->request->session(); $lang = 'en'; if (isset($this->request->params['lang'])) { $lang = $this->request->params['lang']; } else { if ($session->check('Config.language')) { $lang = $session->read('Config.language'); } } $session->write('Config.language', $lang); // Change current language by post request if ($this->request->is('post') && isset($this->request->data['language'])) { $newLang = $this->request->data['language']; $transUrl = $this->translateUrl($newLang); $this->redirect($transUrl); } $this->set('lang', $lang); $this->set('controller', $this->name); I18n::locale($lang); Time::setToStringFormat('YYYY-MM-dd HH:mm:ss'); Type::build('datetime')->useLocaleParser(); $this->Auth->config(['unauthorizedRedirect' => false]); $this->Auth->allow(['login', 'init']); $user = $this->Auth->user(); if (isset($user)) { $username = $user['username']; $this->set(['is_authorized' => true, 'username' => $username]); } else { $this->set('is_authorized', false); } }
/** * Setup * * @return void */ public function setUp() { parent::setUp(); $this->type = Type::build('float'); $this->driver = $this->getMock('Cake\\Database\\Driver'); $this->locale = I18n::locale(); I18n::locale($this->locale); }
public function setUp() { parent::setUp(); $this->type = Type::build('money'); $this->driver = $this->getMock('Cake\\Database\\Driver'); $this->_originalLocale = Money::$defaultLocale; $this->_originalMap = Type::map(); }
/** * Build the map of property => marshalling callable. * * @param array $data The data being marshalled. * @param array $options List of options containing the 'associated' key. * @throws \InvalidArgumentException When associations do not exist. * @return array */ protected function _buildPropertyMap($data, $options) { $map = []; $schema = $this->_table->schema(); // Is a concrete column? foreach (array_keys($data) as $prop) { $columnType = $schema->columnType($prop); if ($columnType) { $map[$prop] = function ($value, $entity) use($columnType) { return Type::build($columnType)->marshal($value); }; } } // Map associations if (!isset($options['associated'])) { $options['associated'] = []; } $include = $this->_normalizeAssociations($options['associated']); foreach ($include as $key => $nested) { if (is_int($key) && is_scalar($nested)) { $key = $nested; $nested = []; } $assoc = $this->_table->association($key); // If the key is not a special field like _ids or _joinData // it is a missing association that we should error on. if (!$assoc) { if (substr($key, 0, 1) !== '_') { throw new \InvalidArgumentException(sprintf('Cannot marshal data for "%s" association. It is not associated with "%s".', $key, $this->_table->alias())); } continue; } if (isset($options['forceNew'])) { $nested['forceNew'] = $options['forceNew']; } if (isset($options['isMerge'])) { $callback = function ($value, $entity) use($assoc, $nested) { $options = $nested + ['associated' => []]; return $this->_mergeAssociation($entity->get($assoc->property()), $assoc, $value, $options); }; } else { $callback = function ($value, $entity) use($assoc, $nested) { $options = $nested + ['associated' => []]; return $this->_marshalAssociation($assoc, $value, $options); }; } $map[$assoc->property()] = $callback; } $behaviors = $this->_table->behaviors(); foreach ($behaviors->loaded() as $name) { $behavior = $behaviors->get($name); if ($behavior instanceof PropertyMarshalInterface) { $map += $behavior->buildMarshalMap($this, $map, $options); } } return $map; }
/** * Setup * * @return void */ public function setUp() { parent::setUp(); $this->type = Type::build('float'); $this->driver = $this->getMockBuilder('Cake\\Database\\Driver')->getMock(); $this->locale = I18n::locale(); $this->numberClass = FloatType::$numberClass; I18n::locale($this->locale); }
/** * Returns an array with the types that require values to * be casted to expressions, out of the list of type names * passed as parameter. * * @param array $types List of type names * @return array */ protected function _requiresToExpressionCasting($types) { $result = []; $types = array_filter($types); foreach ($types as $k => $type) { $object = Type::build($type); if ($object instanceof ExpressionTypeInterface) { $result[$k] = $object; } } return $result; }
/** * {@inheritDoc} * * @return void */ public function lock($by = null, $session = null) { if ($this->isLocked() && $by !== $this->lockOwner()) { throw new LockingException('This entity is already locked'); } $this->set('locked_time', Type::build('datetime')->marshal(time())); if ($by !== null) { $this->set('locked_by', $by); } if ($session !== null) { $this->set('locked_session', $session); } }
/** * Custom finder to retrieve decrypted values. * * @param \Cake\ORM\Query $query Query. * @param array $options Options. * @return \Cake\ORM\Query */ public function findDecrypted(Query $query, array $options) { $options += ['fields' => []]; $mapper = function ($row) use($options) { $driver = $this->_table->connection()->driver(); foreach ($this->config('fields') as $field => $type) { if ($options['fields'] && !in_array($field, (array) $options['fields']) || !$row->has($field)) { continue; } $cipher = $row->get($field); $plain = $this->decrypt($cipher); $row->set($field, Type::build($type)->toPHP($plain, $driver)); } return $row; }; $formatter = function ($results) use($mapper) { return $results->map($mapper); }; return $query->formatResults($formatter); }
/** * Setup * * @return void */ public function setUp() { parent::setUp(); $this->type = Type::build('string'); $this->driver = $this->getMockBuilder('Cake\\Database\\Driver')->getMock(); }
/** * Marshalls flat data into PHP objects. * * @param mixed $value The value to convert * @param string $type Type identifier, `integer`, `float`, etc * @return mixed Converted value */ public function marshal($value, $type) { return Type::build($type)->marshal($value); }
* Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more * advanced ways of loading plugins * * Plugin::loadAll(); // Loads all plugins at once * Plugin::load('Migrations'); //Loads a single plugin named Migrations * */ Plugin::load('Migrations'); // Only try to load DebugKit in development mode // Debug Kit should not be installed on a production system if (Configure::read('debug')) { Plugin::load('DebugKit', ['bootstrap' => true]); } /** * Connect middleware/dispatcher filters. */ DispatcherFactory::add('Asset'); DispatcherFactory::add('Routing'); DispatcherFactory::add('ControllerFactory'); /** * Enable immutable time objects in the ORM. * * You can enable default locale format parsing by adding calls * to `useLocaleParser()`. This enables the automatic conversion of * locale specific date formats. For details see * @link http://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data */ Type::build('time')->useImmutable(); Type::build('date')->useImmutable(); Type::build('datetime')->useImmutable(); Plugin::load('AkkaFacebook', ['bootstrap' => false, 'routes' => true]);
/** * Generate a primary key value for a new record. * * By default, this uses the type system to generate a new primary key * value if possible. You can override this method if you have specific requirements * for id generation. * * @param array $primary The primary key columns to get a new ID for. * @return mixed Either null or the new primary key value. */ protected function _newId($primary) { if (!$primary || count((array) $primary) > 1) { return null; } $typeName = $this->schema()->columnType($primary[0]); $type = Type::build($typeName); return $type->newId(); }
/** * Plugins need to be loaded manually, you can either load them one by one or all of them in a single call * Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more * advanced ways of loading plugins * * Plugin::loadAll(); // Loads all plugins at once * Plugin::load('Migrations'); //Loads a single plugin named Migrations * */ Plugin::load('Migrations'); // Only try to load DebugKit in development mode // Debug Kit should not be installed on a production system if (Configure::read('debug')) { Plugin::load('DebugKit', ['bootstrap' => true]); } /** * Connect middleware/dispatcher filters. */ DispatcherFactory::add('Asset'); DispatcherFactory::add('Routing'); DispatcherFactory::add('ControllerFactory'); /** * Enable default locale format parsing. * This is needed for matching the auto-localized string output of Time() class when parsing dates. * * Also enable immutable time objects in the ORM. */ Type::build('time')->useImmutable()->useLocaleParser(); Type::build('date')->useImmutable()->useLocaleParser(); Type::build('datetime')->useImmutable()->useLocaleParser();
public function mentionToDB() { $this->autoRender = false; $this->Markers = TableRegistry::get('Markers'); // first get the latest twitID from DB $getLatestTwitID = $this->Markers->find()->select(['twitID'])->where(['active' => true, 'twitID IS NOT' => null])->order(['twitID' => 'DESC'])->first(); if ($getLatestTwitID['twitID'] > 0) { $latestTwitID = $getLatestTwitID['twitID']; } else { //$latestTwitID = 642008117992001536;//first test twit mentioning @macetsurabaya $latestTwitID = 1; } // second grab twit $dataStream = $this->getMention($latestTwitID, 800); $countDataStream = count($dataStream); $dataToDisplay = []; // @todo better to return no data message after if ($countDataStream > 0) { foreach ($dataStream as $data) { if ($data['place'] !== null) { $isTwitExists = $this->Markers->exists(['twitID' => $data['id'], 'active' => 1]); if (!$isTwitExists) { //$dataToDisplay[] = $data; //if geo located, insert to DB //first get respondent_id $respondent_id = $this->findToSaveRespondent($data['user']['id'], $data['user']['name'], $data['user']['screen_name']); $info = trim(str_replace('@dimanamacetid', '', $data['text'])); $created_at = date("Y-m-d H:i:s", strtotime($data['created_at'])); Type::build('datetime')->useLocaleParser(); //cakephp need this to save datetime field $dataToSave = ['category_id' => 1, 'user_id' => 4, 'respondent_id' => $respondent_id, 'weather_id' => 1, 'twitID' => $data['id'], 'twitTime' => new Time($created_at), 'twitURL' => null, 'twitPlaceID' => $data['place']['id'], 'twitPlaceName' => $data['place']['name'], 'isTwitPlacePrecise' => 0, 'twitImage' => null, 'pinned' => 0, 'cleared' => 0, 'active' => 1]; // if image do exists if (array_key_exists('extended_entities', $data) && array_key_exists('media', $data['extended_entities']) && $data['extended_entities']['media'][0]['type'] == 'photo') { $dataToSave['twitImage'] = $data['extended_entities']['media'][0]['media_url_https']; } // if url do exists $twitURL = $this->findURLonText($info); if ($twitURL !== null) { $dataToSave['twitURL'] = $twitURL; $info = str_ireplace($twitURL, "", $info); $info = trim($info); } $dataToSave['info'] = $info; // category_id and weather_id based on twit $twitHashtagCategoryWeather = $this->findHashtagonText($info); $dataToSave['category_id'] = $twitHashtagCategoryWeather[0]; $dataToSave['weather_id'] = $twitHashtagCategoryWeather[1]; //$dataToSave['info'] = $twitHashtagCategoryWeather[2]; // if get precise location if ($data['geo'] !== null) { $dataToSave['lat'] = $data['geo']['coordinates'][0]; $dataToSave['lng'] = $data['geo']['coordinates'][1]; $dataToSave['isTwitPlacePrecise'] = 1; } else { $dataToSave['lat'] = $data['place']['bounding_box']['coordinates'][0][0][1]; $dataToSave['lng'] = $data['place']['bounding_box']['coordinates'][0][0][0]; } //$dataToDisplay[] = $dataToSave; //save marker $marker = $this->Markers->newEntity($dataToSave); $this->Markers->save($marker); } } } } /*$this->set([ 'latestTwitID' => $getLatestTwitID, 'data' => $dataToDisplay, 'meta' => $countDataStream, '_serialize' => ['latestTwitID', 'data', 'meta'] ]);*/ }
/** * Helps converting data to correct type * @param Event $event Event object * @param ArrayObject $data Data array to be marshalled * @param ArrayObject $options Marshall option array * @return void */ public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) { $fields = $this->config('fields'); foreach ($fields as $field => $type) { if (isset($data[$field])) { $data[$field] = Type::build($type)->marshal($data[$field]); } } }
/** * Tests integers from PHP are converted correctly to statement value * * @return void */ public function testDecimalToStatement() { $type = Type::build('decimal'); $string = '12.55'; $driver = $this->getMock('\\Cake\\Database\\Driver'); $this->assertEquals(PDO::PARAM_STR, $type->toStatement($string, $driver)); }
namespace App\Controller; use Cake\Controller\Controller; use Cake\Event\Event; use Cake\Database\Type; use Cake\I18n\I18n; use Cake\I18n\Time; use Cake\I18n\Number; I18n::locale('pt_BR'); // Habilita o parseamento de datas localizadas Type::build('date')->useLocaleParser()->setLocaleFormat('dd/M/yyyy'); Type::build('datetime')->useLocaleParser()->setLocaleFormat('dd/M/yyyy HH:ii:ss'); Type::build('timestamp')->useLocaleParser()->setLocaleFormat('dd/M/yyyy HH:ii:ss'); // Habilita o parseamento de decimal localizaddos Type::build('decimal')->useLocaleParser(); Type::build('float')->useLocaleParser(); /** * Application Controller * * Add your application-wide methods in the class below, your controllers * will inherit them. * * @link http://book.cakephp.org/3.0/en/controllers.html#the-app-controller */ class AppController extends Controller { public $helpers = ['Html' => ['className' => 'MyHtml'], 'Form' => ['className' => 'MyForm'], 'Paginator' => ['className' => 'MyPaginator'], 'Modal' => ['className' => 'MyModal']]; public function __construct(\Cake\Network\Request $request = null, \Cake\Network\Response $response = null, $name = null, $eventManager = null, $components = null) { parent::__construct($request, $response, $name, $eventManager, $components); $this->set('bt_consultar_acao', true);
// Debug Kit should not be installed on a production system if (Configure::read('debug')) { Plugin::load('DebugKit', ['bootstrap' => true]); } /** * Connect middleware/dispatcher filters. */ DispatcherFactory::add('Asset'); DispatcherFactory::add('Routing'); DispatcherFactory::add('ControllerFactory'); /** * Enable default locale format parsing. * This is needed for matching the auto-localized string output of Time() class when parsing dates. */ Type::build('date')->useLocaleParser()->setLocaleFormat('d/m/y'); Type::build('datetime')->useLocaleParser()->setLocaleFormat('d/m/y H:i:s'); define('REGISTRO_DESPESA', 1); define('REGISTRO_RECEITA', 2); define('EXCLUSAO_LANCAMENTO', 3); define('CADASTRO_CATEGORIA', 4); define('EDICAO_CATEGORIA', 5); define('EXCLUSAO_CATEGORIA', 6); define('CADASTRO_FORMA_PAGAMENTO', 7); define('EDICAO_FORMA_PAGAMENTO', 8); define('EXCLUSAO_FORMA_PAGAMENTO', 9); define('CADASTRO_CONTA', 10); define('EDICAO_CONTA', 11); define('EXCLUSAO_CONTA', 12); define('CADASTRO_FORNECEDOR', 13); define('EDICAO_FORNECEDOR', 14); define('EXCLUSAO_FORNECEDOR', 15);
/** * Merges `$data` into `$entity` and recursively does the same for each one of * the association names passed in `$include`. When merging associations, if an * entity is not present in the parent entity for a given association, a new one * will be created. * * When merging HasMany or BelongsToMany associations, all the entities in the * `$data` array will appear, those that can be matched by primary key will get * the data merged, but those that cannot, will be discarded. * * @param \Cake\Datasource\EntityInterface $entity the entity that will get the * data merged in * @param array $data key value list of fields to be merged into the entity * @param array $include The list of associations to be merged * @return \Cake\Datasource\EntityInterface */ public function merge(EntityInterface $entity, array $data, array $include = []) { $propertyMap = $this->_buildPropertyMap($include); $tableName = $this->_table->alias(); if (isset($data[$tableName])) { $data = $data[$tableName]; } $schema = $this->_table->schema(); $properties = []; foreach ($data as $key => $value) { $columnType = $schema->columnType($key); $original = $entity->get($key); if (isset($propertyMap[$key])) { $assoc = $propertyMap[$key]['association']; $nested = $propertyMap[$key]['nested']; $value = $this->_mergeAssociation($original, $assoc, $value, $nested); } elseif ($columnType) { $converter = Type::build($columnType); $value = $converter->marshal($value); if ($original == $value) { continue; } } $properties[$key] = $value; } $entity->set($properties); return $entity; }
/** * Merges `$data` into `$entity` and recursively does the same for each one of * the association names passed in `$options`. When merging associations, if an * entity is not present in the parent entity for a given association, a new one * will be created. * * When merging HasMany or BelongsToMany associations, all the entities in the * `$data` array will appear, those that can be matched by primary key will get * the data merged, but those that cannot, will be discarded. `ids` option can be used * to determine whether the association must use the `_ids` format. * * ### Options: * * - associated: Associations listed here will be marshalled as well. * - validate: Whether or not to validate data before hydrating the entities. Can * also be set to a string to use a specific validator. Defaults to true/default. * - fieldList: A whitelist of fields to be assigned to the entity. If not present * the accessible fields list in the entity will be used. * - accessibleFields: A list of fields to allow or deny in entity accessible fields. * * The above options can be used in each nested `associated` array. In addition to the above * options you can also use the `onlyIds` option for HasMany and BelongsToMany associations. * When true this option restricts the request data to only be read from `_ids`. * * ``` * $result = $marshaller->merge($entity, $data, [ * 'associated' => ['Tags' => ['onlyIds' => true]] * ]); * ``` * * @param \Cake\Datasource\EntityInterface $entity the entity that will get the * data merged in * @param array $data key value list of fields to be merged into the entity * @param array $options List of options. * @return \Cake\Datasource\EntityInterface */ public function merge(EntityInterface $entity, array $data, array $options = []) { list($data, $options) = $this->_prepareDataAndOptions($data, $options); $propertyMap = $this->_buildPropertyMap($options); $isNew = $entity->isNew(); $keys = []; if (!$isNew) { $keys = $entity->extract((array) $this->_table->primaryKey()); } if (isset($options['accessibleFields'])) { foreach ((array) $options['accessibleFields'] as $key => $value) { $entity->accessible($key, $value); } } $errors = $this->_validate($data + $keys, $options, $isNew); $schema = $this->_table->schema(); $properties = $marshalledAssocs = []; foreach ($data as $key => $value) { if (!empty($errors[$key])) { if ($entity instanceof InvalidPropertyInterface) { $entity->invalid($key, $value); } continue; } $columnType = $schema->columnType($key); $original = $entity->get($key); if (isset($propertyMap[$key])) { $assoc = $propertyMap[$key]['association']; $value = $this->_mergeAssociation($original, $assoc, $value, $propertyMap[$key]); $marshalledAssocs[$key] = true; } elseif ($columnType) { $converter = Type::build($columnType); $value = $converter->marshal($value); $isObject = is_object($value); if (!$isObject && $original === $value || $isObject && $original == $value) { continue; } } $properties[$key] = $value; } if (!isset($options['fieldList'])) { $entity->set($properties); $entity->errors($errors); foreach (array_keys($marshalledAssocs) as $field) { if ($properties[$field] instanceof EntityInterface) { $entity->dirty($field, $properties[$field]->dirty()); } } return $entity; } foreach ((array) $options['fieldList'] as $field) { if (array_key_exists($field, $properties)) { $entity->set($field, $properties[$field]); if ($properties[$field] instanceof EntityInterface && isset($marshalledAssocs[$field])) { $entity->dirty($field, $properties[$field]->dirty()); } } } $entity->errors($errors); return $entity; }
/** * Returns the base type name for the provided column. * This represent the database type a more complex class is * based upon. * * @param string $column The column name to get the base type from * @return string The base type name */ public function baseColumnType($column) { if (isset($this->_columns[$column]['baseType'])) { return $this->_columns[$column]['baseType']; } $type = $this->columnType($column); if ($type === null) { return null; } if (Type::map($type)) { $type = Type::build($type)->getBaseType(); } return $this->_columns[$column]['baseType'] = $type; }
/** * Setup * * @return void */ public function setUp() { parent::setUp(); $this->type = Type::build('uuid'); $this->driver = $this->getMock('Cake\\Database\\Driver'); }
public function add() { $letter = $this->Letters->newEntity(); if ($this->request->is('post')) { $errorMessages = []; /** * letter = * [ * sender_id, * user_id, * via_id, * number, * date, * content, * created = null, * modified = null, * isread = false, * active = true, * senderName = lorem, * fileName = 1.png, * dispositions = [], * evidences = [], * sender = null, * user = null, * via = null, * * ] */ unset($this->request->data['letter']['active']); unset($this->request->data['letter']['created']); unset($this->request->data['letter']['modified']); $this->request->data['letter']['created'] = null; $this->request->data['letter']['modified'] = null; $this->request->data['letter']['active'] = true; $date = date("Y-m-d", strtotime($this->request->data['letter']['date'])); Type::build('datetime')->useLocaleParser(); //cakephp need this to save datetime field $this->request->data['letter']['date'] = new Time($date); if ($this->request->data['letter']['user_id'] === null) { $errorMessages[] = 'Pengguna tidak sah'; } if ($this->request->data['letter']['number'] === null) { $errorMessages[] = 'Nomor tidak boleh kosong'; } if ($this->request->data['letter']['content'] === null) { $errorMessages[] = 'Perihal tidak boleh kosong'; } if ($this->request->data['letter']['senderName'] === null) { $errorMessages[] = 'Pengirim tidak boleh kosong'; } else { $this->request->data['letter']['sender_id'] = $this->Letters->Senders->findAndSave($this->request->data['letter']['senderName']); } if ($this->request->data['letter']['fileName'] === null) { $errorMessages[] = 'Berkas harus sudah diunggah'; } if (count($errorMessages) > 0) { $dataToReturn = $errorMessages; } else { $letter = $this->Letters->patchEntity($letter, $this->request->data['letter']); if ($this->Letters->save($letter)) { $letterId = $letter->id; // save evidences table and rename file uploaded $this->Letters->Evidences->saveAndRenameLetterJoin($this->request->data['letter']['fileName'], 1, $letterId); $dataToReturn = 1; } else { $dataToReturn = $letter; } } $this->set(['letter' => $dataToReturn, '_serialize' => ['letter']]); } }
/** * Test setting instances into the factory/registry. * * @return void */ public function testSet() { $instance = $this->getMock('Cake\\Database\\Type'); Type::set('random', $instance); $this->assertSame($instance, Type::build('random')); }
/** * Casts all values from a row brought from a table to the correct * PHP type. * * @param Table $table The table object * @param array $values The values to cast * @return array */ protected function _castValues($table, $values) { $alias = $table->alias(); $driver = $this->_query->connection()->driver(); if (empty($this->types[$alias])) { $schema = $table->schema(); foreach ($schema->columns() as $col) { $this->types[$alias][$col] = Type::build($schema->columnType($col)); } } foreach ($values as $field => $value) { if (!isset($this->types[$alias][$field])) { continue; } $values[$field] = $this->types[$alias][$field]->toPHP($value, $driver); } return $values; }
* Inflector::rules('transliteration', ['/å/' => 'aa']); */ /** * Plugins need to be loaded manually, you can either load them one by one or all of them in a single call * Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more * advanced ways of loading plugins * * Plugin::loadAll(); // Loads all plugins at once * Plugin::load('Migrations'); //Loads a single plugin named Migrations * */ Plugin::load('Migrations'); // Only try to load DebugKit in development mode // Debug Kit should not be installed on a production system if (Configure::read('debug')) { Plugin::load('DebugKit', ['bootstrap' => true]); } /** * Connect middleware/dispatcher filters. */ DispatcherFactory::add('Asset'); DispatcherFactory::add('Routing'); DispatcherFactory::add('ControllerFactory'); /** * Enable default locale format parsing. * This is needed for matching the auto-localized string output of Time() class when parsing dates. */ Type::build('date')->useLocaleParser(); Type::build('datetime')->useLocaleParser(); Plugin::load('BoxManager', ['bootstrap' => false, 'routes' => true]); Plugin::load('SocialManager', ['bootstrap' => false, 'routes' => true]);
/** * testBadAssertNoRedirect * * @return void */ public function testNotCallableMethod() { /** @var IpType $ipType */ $ipType = Type::build('ip'); $ipType->_encode = 'not_a_callable'; $ipType->_decode = 'not_a_callable'; try { $this->Ips->find()->all()->toArray(); } catch (\Exception $e) { $this->assertTrue($e instanceof \UnexpectedValueException); return; } $this->assertTrue(false); }