当前位置: 首页>>代码示例>>PHP>>正文


PHP Assert::isEqual方法代码示例

本文整理汇总了PHP中Assert::isEqual方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::isEqual方法的具体用法?PHP Assert::isEqual怎么用?PHP Assert::isEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Assert的用法示例。


在下文中一共展示了Assert::isEqual方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: importValue

 public function importValue($value)
 {
     if ($value) {
         Assert::isEqual(get_class($value), $this->className);
     } else {
         return parent::importValue(null);
     }
     return $this->import(array($this->getName() => $value->getId()));
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:9,代码来源:PrimitiveEnum.class.php

示例2: fillOwn

 /**
  * @return Form
  **/
 public function fillOwn($object, &$result)
 {
     Assert::isInstance($result, 'Form');
     foreach ($this->getFormMapping() as $primitive) {
         if ($primitive instanceof PrimitiveForm && $result->exists($primitive->getName()) && $primitive->isComposite()) {
             Assert::isEqual($primitive->getProto(), $result->get($primitive->getName())->getProto());
             continue;
         }
         $result->add($primitive);
     }
     $result = parent::fillOwn($object, $result);
     $result->setProto($this->proto);
     return $result;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:17,代码来源:FormBuilder.class.php

示例3: copyProperties

 public static function copyProperties($source, $destination)
 {
     Assert::isEqual(get_class($source), get_class($destination));
     $class = new ReflectionClass($source);
     foreach ($class->getProperties() as $property) {
         $name = ucfirst($property->getName());
         $getter = 'get' . $name;
         $setter = 'set' . $name;
         if ($class->hasMethod($getter) && $class->hasMethod($setter)) {
             $sourceValue = $source->{$getter}();
             if ($sourceValue === null) {
                 $setMethood = $class->getMethod($setter);
                 $parameterList = $setMethood->getParameters();
                 $firstParameter = $parameterList[0];
                 if ($firstParameter->allowsNull()) {
                     $destination->{$setter}($sourceValue);
                 }
             } else {
                 $destination->{$setter}($sourceValue);
             }
         }
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:23,代码来源:ClassUtils.class.php

示例4: checkIntegrity

 /**
  * @return MetaConfiguration
  **/
 public function checkIntegrity()
 {
     $out = $this->getOutput()->newLine()->infoLine('Checking sanity of generated files: ')->newLine();
     set_include_path(get_include_path() . PATH_SEPARATOR . ONPHP_META_BUSINESS_DIR . PATH_SEPARATOR . ONPHP_META_DAO_DIR . PATH_SEPARATOR . ONPHP_META_PROTO_DIR . PATH_SEPARATOR . ONPHP_META_AUTO_BUSINESS_DIR . PATH_SEPARATOR . ONPHP_META_AUTO_DAO_DIR . PATH_SEPARATOR . ONPHP_META_AUTO_PROTO_DIR . PATH_SEPARATOR);
     $out->info("\t");
     $formErrors = array();
     foreach ($this->classes as $name => $class) {
         if (!($class->getPattern() instanceof SpookedClassPattern || $class->getPattern() instanceof SpookedEnumerationPattern || $class->getPattern() instanceof InternalClassPattern) && class_exists($class->getName(), true)) {
             $out->info($name, true);
             $info = new ReflectionClass($name);
             $this->checkClassSanity($class, $info);
             if ($info->implementsInterface('Prototyped')) {
                 $this->checkClassSanity($class, new ReflectionClass('Proto' . $name));
             }
             if ($info->implementsInterface('DAOConnected')) {
                 $this->checkClassSanity($class, new ReflectionClass($name . 'DAO'));
             }
             foreach ($class->getInterfaces() as $interface) {
                 Assert::isTrue($info->implementsInterface($interface), 'class ' . $class->getName() . ' expected to implement interface ' . $interface);
             }
             // special handling for Enumeration instances
             if ($class->getPattern() instanceof EnumerationClassPattern) {
                 $object = new $name(call_user_func(array($name, 'getAnyId')));
                 Assert::isTrue(unserialize(serialize($object)) == $object);
                 $out->info(', ');
                 if ($this->checkEnumerationRefIntegrity) {
                     $this->checkEnumerationReferentialIntegrity($object, $class->getTableName());
                 }
                 continue;
             }
             if ($class->getPattern() instanceof AbstractClassPattern) {
                 $out->info(', ');
                 continue;
             }
             $object = new $name();
             $proto = $object->proto();
             $form = $proto->makeForm();
             foreach ($class->getProperties() as $name => $property) {
                 Assert::isTrue($property->toLightProperty($class) == $proto->getPropertyByName($name), 'defined property does not match autogenerated one - ' . $class->getName() . '::' . $property->getName());
             }
             if (!$object instanceof DAOConnected) {
                 $out->info(', ');
                 continue;
             }
             $dao = $object->dao();
             Assert::isEqual($dao->getIdName(), $class->getIdentifier()->getColumnName(), 'identifier name mismatch in ' . $class->getName() . ' class');
             try {
                 DBPool::getByDao($dao);
             } catch (MissingElementException $e) {
                 // skipping
                 $out->info(', ');
                 continue;
             }
             $query = Criteria::create($dao)->setLimit(1)->add(Expression::notNull($class->getIdentifier()->getName()))->addOrder($class->getIdentifier()->getName())->toSelectQuery();
             $out->warning(' (' . $query->getFieldsCount() . '/' . $query->getTablesCount() . '/');
             $clone = clone $object;
             if (serialize($clone) == serialize($object)) {
                 $out->info('C', true);
             } else {
                 $out->error('C', true);
             }
             $out->warning('/');
             try {
                 $object = $dao->getByQuery($query);
                 $form = $object->proto()->makeForm();
                 FormUtils::object2form($object, $form);
                 if ($errors = $form->getErrors()) {
                     $formErrors[$class->getName()] = $errors;
                     $out->error('F', true);
                 } else {
                     $out->info('F', true);
                 }
             } catch (ObjectNotFoundException $e) {
                 $out->warning('F');
             }
             $out->warning('/');
             if (Criteria::create($dao)->setFetchStrategy(FetchStrategy::cascade())->toSelectQuery() == $dao->makeSelectHead()) {
                 $out->info('H', true);
             } else {
                 $out->error('H', true);
             }
             $out->warning('/');
             // cloning once again
             $clone = clone $object;
             FormUtils::object2form($object, $form);
             FormUtils::form2object($form, $object);
             if ($object != $clone) {
                 $out->error('T', true);
             } else {
                 $out->info('T', true);
             }
             $out->warning(')')->info(', ');
         }
     }
     $out->infoLine('done.');
     if ($formErrors) {
         $out->newLine()->errorLine('Errors found:')->newLine();
//.........这里部分代码省略.........
开发者ID:rero26,项目名称:onphp-framework,代码行数:101,代码来源:MetaConfiguration.class.php

示例5: getCovariance

 public static function getCovariance(array $list1, array $list2)
 {
     $list1Size = count($list1);
     $list2Size = count($list2);
     Assert::isEqual($list1Size, $list2Size, 'Array sizes should be equals!');
     $list1AverageValue = self::getAverage($list1);
     $list2AverageValue = self::getAverage($list2);
     $tempSum = 0;
     for ($i = 0; $i < $list1Size; $i++) {
         $elt1Dev = self::getMeanDeviation($list1[$i], $list1AverageValue);
         $elt2Dev = self::getMeanDeviation($list2[$i], $list2AverageValue);
         $tempSum += $elt1Dev * $elt2Dev;
     }
     return $tempSum / ($list1Size - 1);
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:15,代码来源:MathUtils.class.php

示例6: assertSavePointName

 private function assertSavePointName($savepointName)
 {
     Assert::isEqual(1, preg_match('~^[A-Za-z][A-Za-z0-9]*$~iu', $savepointName));
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:4,代码来源:DB.class.php

示例7: call

 protected function call($method, DTOMessage $request, $resultClass)
 {
     $requestDto = $request->makeDto();
     Assert::isInstance($requestDto, 'DTOClass');
     if (defined('__LOCAL_DEBUG__') && !defined('SIMPLE_TEST')) {
         // self-validation
         $form = ObjectToFormConverter::create($request->entityProto())->make($request);
         Assert::isTrue(!$form->getErrors() && $request->entityProto()->validate($request, $form), Assert::dumpArgument($request));
     }
     try {
         try {
             $resultDto = $this->getSoapClient()->{$method}($requestDto);
         } catch (BaseException $e) {
             if (get_class($e) == 'BaseException') {
                 throw new SoapFault('Server', get_class($e) . ': ' . $e->getMessage());
             } else {
                 $this->logCall();
                 throw $e;
             }
         }
     } catch (SoapFault $e) {
         $this->logCall();
         throw self::convertSoapFault($e);
     }
     $this->logCall();
     if (!$resultClass) {
         Assert::isNull($resultDto);
         $result = null;
     } else {
         Assert::isInstance($resultDto, 'DTOClass');
         Assert::isEqual($resultDto->entityProto()->className(), $resultClass);
         $form = DTOToFormImporter::create($resultDto->entityProto())->make($resultDto);
         Assert::isTrue(!$form->getErrors(), Assert::dumpArgument($resultDto));
         $result = $resultDto->makeObject($form);
         Assert::isInstance($result, 'DTOMessage');
         Assert::isEqual(get_class($result), $resultClass);
         Assert::isTrue($result->entityProto()->validate($result, $form), Assert::dumpArgument($result));
     }
     return $result;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:40,代码来源:PrototypedSoapClient.class.php

示例8: __construct

 private function __construct($name)
 {
     $units = self::getUnits();
     if (!isset($units[$name])) {
         throw new WrongArgumentException("know nothing about unit '{$name}'");
     }
     if (!$units[$name]) {
         throw new UnimplementedFeatureException('need for complex logic, see manual');
     }
     $this->name = $name;
     $this->months = $units[$name][0];
     $this->days = $units[$name][1];
     $this->seconds = $units[$name][2];
     $notNulls = 0;
     if ($this->months > 0) {
         ++$notNulls;
     }
     if ($this->days > 0) {
         ++$notNulls;
     }
     if ($this->seconds > 0) {
         ++$notNulls;
     }
     Assert::isEqual($notNulls, 1, "broken unit '{$name}'");
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:25,代码来源:IntervalUnit.class.php

示例9: hex2Binary

 public static function hex2Binary($hex)
 {
     $length = strlen($hex);
     Assert::isEqual($length % 2, 0);
     $out = null;
     for ($i = 0; $i < $length; $i += 2) {
         $out .= pack('C', hexdec(substr($hex, $i, 2)));
     }
     return $out;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:10,代码来源:TextUtils.class.php

示例10: setChars

 public static function setChars($chars)
 {
     self::check($chars);
     Assert::isEqual(mb_strlen($chars), 62, 'Wrong length');
     self::$chars = $chars;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:6,代码来源:Base62Utils.class.php

示例11: validateList

 public final function validateList($objectsList, $formsList, $previousObjectsList = null)
 {
     Assert::isEqual(count($objectsList), count($formsList));
     reset($formsList);
     if ($previousObjectsList) {
         Assert::isEqual(count($objectsList), count($previousObjectsList));
         reset($previousObjectsList);
     }
     $result = true;
     $previousObject = null;
     foreach ($objectsList as $object) {
         $form = current($formsList);
         next($formsList);
         if ($previousObjectsList) {
             $previousObject = current($previousObjectsList);
             next($previousObjectsList);
         }
         if (!$this->validate($object, $form, $previousObject)) {
             $result = false;
         }
     }
     return $result;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:23,代码来源:EntityProto.class.php

示例12: makeUniqueLatinName

 public static function makeUniqueLatinName($originalName)
 {
     $extension = substr($originalName, strrpos($originalName, '.'));
     Assert::isEqual(preg_match('/\\.[^0-9a-zA-Z]/', $extension), 0, 'I don\'t know how to work with this extension: ' . $extension);
     return time() . '_' . uniqid() . $extension;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:6,代码来源:FileUtils.class.php

示例13: endPrefetch

 public function endPrefetch(array $objectList)
 {
     if (!$this->depth) {
         throw new WrongStateException('prefetch mode is already off');
     }
     foreach ($this->storage[$this->depth] as $setter => $innerList) {
         Assert::isEqual(count($objectList), count($innerList) + array_sum($this->skipList[$this->depth]));
         $ids = array();
         foreach ($innerList as $inner) {
             if ($inner) {
                 $ids[] = $inner->getId();
             }
         }
         // finding first available inner object
         foreach ($innerList as $inner) {
             if ($inner) {
                 break;
             }
         }
         if (!$inner) {
             continue;
         }
         // put yet unmapped objects into dao's identityMap
         $inner->dao()->getListByIds($ids);
         $skippedMap = $this->skipList[$this->depth];
         $i = $j = 0;
         foreach ($objectList as $object) {
             $objectId = $object->getId();
             if (isset($skippedMap[$objectId])) {
                 if ($skippedMap[$objectId] == 1) {
                     unset($skippedMap[$objectId]);
                 } else {
                     --$skippedMap[$objectId];
                 }
                 ++$j;
                 continue;
             }
             if ($innerList[$i]) {
                 try {
                     // avoid dao "caching" here
                     // because of possible breakage
                     // in overriden properties
                     $object->{$setter}($innerList[$i]->dao()->getById($innerList[$i]->getId()));
                 } catch (ObjectNotFoundException $e) {
                     throw new WrongStateException('possible corruption found: ' . $e->getMessage());
                 }
             }
             ++$i;
         }
         Assert::isEqual($i, count($objectList) - $j);
     }
     unset($this->skipList[$this->depth], $this->storage[$this->depth--]);
     return $objectList;
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:54,代码来源:AbstractProtoClass.class.php


注:本文中的Assert::isEqual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。