Best Phoronix-test-suite code snippet using must.properties
SchemaValidatorTest.php
Source:SchemaValidatorTest.php
...17 {18 $value = array(array(1));19 $this->assertFalse($this->validator->validate($this->getComplexParam(), $value));20 $this->assertEquals(21 array('[Foo][0] must be an array of properties. Got a numerically indexed array.'),22 $this->validator->getErrors()23 );24 }25 public function testValidatesArrayListsContainProperItems()26 {27 $value = array(true);28 $this->assertFalse($this->validator->validate($this->getComplexParam(), $value));29 $this->assertEquals(30 array('[Foo][0] must be of type object'),31 $this->validator->getErrors()32 );33 }34 public function testAddsDefaultValuesInLists()35 {36 $value = array(array());37 $this->assertTrue($this->validator->validate($this->getComplexParam(), $value));38 $this->assertEquals(array(array('Bar' => true)), $value);39 }40 public function testMergesDefaultValuesInLists()41 {42 $value = array(43 array('Baz' => 'hello!'),44 array('Bar' => false)45 );46 $this->assertTrue($this->validator->validate($this->getComplexParam(), $value));47 $this->assertEquals(array(48 array(49 'Baz' => 'hello!',50 'Bar' => true51 ),52 array('Bar' => false)53 ), $value);54 }55 public function testCorrectlyConvertsParametersToArrayWhenArraysArePresent()56 {57 $param = $this->getComplexParam();58 $result = $param->toArray();59 $this->assertInternalType('array', $result['items']);60 $this->assertEquals('array', $result['type']);61 $this->assertInstanceOf('Guzzle\Service\Description\Parameter', $param->getItems());62 }63 public function testAllowsInstanceOf()64 {65 $p = new Parameter(array(66 'name' => 'foo',67 'type' => 'object',68 'instanceOf' => get_class($this)69 ));70 $this->assertTrue($this->validator->validate($p, $this));71 $this->assertFalse($this->validator->validate($p, $p));72 $this->assertEquals(array('[foo] must be an instance of ' . __CLASS__), $this->validator->getErrors());73 }74 public function testEnforcesInstanceOfOnlyWhenObject()75 {76 $p = new Parameter(array(77 'name' => 'foo',78 'type' => array('object', 'string'),79 'instanceOf' => get_class($this)80 ));81 $this->assertTrue($this->validator->validate($p, $this));82 $s = 'test';83 $this->assertTrue($this->validator->validate($p, $s));84 }85 public function testConvertsObjectsToArraysWhenToArrayInterface()86 {87 $o = $this->getMockBuilder('Guzzle\Common\ToArrayInterface')88 ->setMethods(array('toArray'))89 ->getMockForAbstractClass();90 $o->expects($this->once())91 ->method('toArray')92 ->will($this->returnValue(array(93 'foo' => 'bar'94 )));95 $p = new Parameter(array(96 'name' => 'test',97 'type' => 'object',98 'properties' => array(99 'foo' => array('required' => 'true')100 )101 ));102 $this->assertTrue($this->validator->validate($p, $o));103 }104 public function testMergesValidationErrorsInPropertiesWithParent()105 {106 $p = new Parameter(array(107 'name' => 'foo',108 'type' => 'object',109 'properties' => array(110 'bar' => array('type' => 'string', 'required' => true, 'description' => 'This is what it does'),111 'test' => array('type' => 'string', 'minLength' => 2, 'maxLength' => 5),112 'test2' => array('type' => 'string', 'minLength' => 2, 'maxLength' => 2),113 'test3' => array('type' => 'integer', 'minimum' => 100),114 'test4' => array('type' => 'integer', 'maximum' => 10),115 'test5' => array('type' => 'array', 'maxItems' => 2),116 'test6' => array('type' => 'string', 'enum' => array('a', 'bc')),117 'test7' => array('type' => 'string', 'pattern' => '/[0-9]+/'),118 'test8' => array('type' => 'number'),119 'baz' => array(120 'type' => 'array',121 'minItems' => 2,122 'required' => true,123 "items" => array("type" => "string")124 )125 )126 ));127 $value = array(128 'test' => 'a',129 'test2' => 'abc',130 'baz' => array(false),131 'test3' => 10,132 'test4' => 100,133 'test5' => array(1, 3, 4),134 'test6' => 'Foo',135 'test7' => 'abc',136 'test8' => 'abc'137 );138 $this->assertFalse($this->validator->validate($p, $value));139 $this->assertEquals(array(140 '[foo][bar] is a required string: This is what it does',141 '[foo][baz] must contain 2 or more elements',142 '[foo][baz][0] must be of type string',143 '[foo][test2] length must be less than or equal to 2',144 '[foo][test3] must be greater than or equal to 100',145 '[foo][test4] must be less than or equal to 10',146 '[foo][test5] must contain 2 or fewer elements',147 '[foo][test6] must be one of "a" or "bc"',148 '[foo][test7] must match the following regular expression: /[0-9]+/',149 '[foo][test8] must be of type number',150 '[foo][test] length must be greater than or equal to 2',151 ), $this->validator->getErrors());152 }153 public function testHandlesNullValuesInArraysWithDefaults()154 {155 $p = new Parameter(array(156 'name' => 'foo',157 'type' => 'object',158 'required' => true,159 'properties' => array(160 'bar' => array(161 'type' => 'object',162 'required' => true,163 'properties' => array(164 'foo' => array('default' => 'hi')165 )166 )167 )168 ));169 $value = array();170 $this->assertTrue($this->validator->validate($p, $value));171 $this->assertEquals(array('bar' => array('foo' => 'hi')), $value);172 }173 public function testFailsWhenNullValuesInArraysWithNoDefaults()174 {175 $p = new Parameter(array(176 'name' => 'foo',177 'type' => 'object',178 'required' => true,179 'properties' => array(180 'bar' => array(181 'type' => 'object',182 'required' => true,183 'properties' => array('foo' => array('type' => 'string'))184 )185 )186 ));187 $value = array();188 $this->assertFalse($this->validator->validate($p, $value));189 $this->assertEquals(array('[foo][bar] is a required object'), $this->validator->getErrors());190 }191 public function testChecksTypes()192 {193 $p = new SchemaValidator();194 $r = new \ReflectionMethod($p, 'determineType');195 $r->setAccessible(true);196 $this->assertEquals('any', $r->invoke($p, 'any', 'hello'));197 $this->assertEquals(false, $r->invoke($p, 'foo', 'foo'));198 $this->assertEquals('string', $r->invoke($p, 'string', 'hello'));199 $this->assertEquals(false, $r->invoke($p, 'string', false));200 $this->assertEquals('integer', $r->invoke($p, 'integer', 1));201 $this->assertEquals(false, $r->invoke($p, 'integer', 'abc'));202 $this->assertEquals('numeric', $r->invoke($p, 'numeric', 1));203 $this->assertEquals('numeric', $r->invoke($p, 'numeric', '1'));204 $this->assertEquals('number', $r->invoke($p, 'number', 1));205 $this->assertEquals('number', $r->invoke($p, 'number', '1'));206 $this->assertEquals(false, $r->invoke($p, 'numeric', 'a'));207 $this->assertEquals('boolean', $r->invoke($p, 'boolean', true));208 $this->assertEquals('boolean', $r->invoke($p, 'boolean', false));209 $this->assertEquals(false, $r->invoke($p, 'boolean', 'false'));210 $this->assertEquals('null', $r->invoke($p, 'null', null));211 $this->assertEquals(false, $r->invoke($p, 'null', 'abc'));212 $this->assertEquals('array', $r->invoke($p, 'array', array()));213 $this->assertEquals(false, $r->invoke($p, 'array', 'foo'));214 }215 public function testValidatesFalseAdditionalProperties()216 {217 $param = new Parameter(array(218 'name' => 'foo',219 'type' => 'object',220 'properties' => array('bar' => array('type' => 'string')),221 'additionalProperties' => false222 ));223 $value = array('test' => '123');224 $this->assertFalse($this->validator->validate($param, $value));225 $this->assertEquals(array('[foo][test] is not an allowed property'), $this->validator->getErrors());226 $value = array('bar' => '123');227 $this->assertTrue($this->validator->validate($param, $value));228 }229 public function testAllowsUndefinedAdditionalProperties()230 {231 $param = new Parameter(array(232 'name' => 'foo',233 'type' => 'object',234 'properties' => array('bar' => array('type' => 'string'))235 ));236 $value = array('test' => '123');237 $this->assertTrue($this->validator->validate($param, $value));238 }239 public function testValidatesAdditionalProperties()240 {241 $param = new Parameter(array(242 'name' => 'foo',243 'type' => 'object',244 'properties' => array('bar' => array('type' => 'string')),245 'additionalProperties' => array('type' => 'integer')246 ));247 $value = array('test' => 'foo');248 $this->assertFalse($this->validator->validate($param, $value));249 $this->assertEquals(array('[foo][test] must be of type integer'), $this->validator->getErrors());250 }251 public function testValidatesAdditionalPropertiesThatArrayArrays()252 {253 $param = new Parameter(array(254 'name' => 'foo',255 'type' => 'object',256 'additionalProperties' => array(257 'type' => 'array',258 'items' => array('type' => 'string')259 )260 ));261 $value = array('test' => array(true));262 $this->assertFalse($this->validator->validate($param, $value));263 $this->assertEquals(array('[foo][test][0] must be of type string'), $this->validator->getErrors());264 }265 public function testIntegersCastToStringWhenTypeMismatch()266 {267 $param = new Parameter(array('name' => 'test', 'type' => 'string'));268 $value = 12;269 $this->assertTrue($this->validator->validate($param, $value));270 $this->assertEquals('12', $value);271 }272 public function testRequiredMessageIncludesType()273 {274 $param = new Parameter(array('name' => 'test', 'type' => array('string', 'boolean'), 'required' => true));275 $value = null;276 $this->assertFalse($this->validator->validate($param, $value));277 $this->assertEquals(array('[test] is a required string or boolean'), $this->validator->getErrors());278 }279 protected function getComplexParam()280 {281 return new Parameter(array(282 'name' => 'Foo',283 'type' => 'array',284 'required' => true,285 'min' => 1,286 'items' => array(287 'type' => 'object',288 'properties' => array(289 'Baz' => array(290 'type' => 'string',291 ),292 'Bar' => array(293 'required' => true,294 'type' => 'boolean',295 'default' => true296 )297 )298 )299 ));300 }301}...
sfProjectDeployTask.class.php
Source:sfProjectDeployTask.class.php
...35 $this->briefDescription = 'Deploys a project to another server';36 $this->detailedDescription = <<<EOF37The [project:deploy|INFO] task deploys a project on a server:38 [./symfony project:deploy production|INFO]39The server must be configured in [config/properties.ini|COMMENT]:40 [[production]41 host=www.example.com42 port=2243 user=fabien44 dir=/var/www/sfblog/45 type=rsync|INFO]46To automate the deployment, the task uses rsync over SSH.47You must configure SSH access with a key or configure the password48in [config/properties.ini|COMMENT].49By default, the task is in dry-mode. To do a real deployment, you50must pass the [--go|COMMENT] option:51 [./symfony project:deploy --go production|INFO]52Files and directories configured in [config/rsync_exclude.txt|COMMENT] are53not deployed:54 [.svn55 /web/uploads/*56 /cache/*57 /log/*|INFO]58You can also create a [rsync.txt|COMMENT] and [rsync_include.txt|COMMENT] files.59If you need to customize the [rsync*.txt|COMMENT] files based on the server,60you can pass a [rsync-dir|COMMENT] option:61 [./symfony project:deploy --go --rsync-dir=config/production production|INFO]62Last, you can specify the options passed to the rsync executable, using the63[rsync-options|INFO] option (defaults are [-azC --force --delete --progress|INFO]):64 [./symfony project:deploy --go --rsync-options=-avz|INFO]65EOF;66 }67 /**68 * @see sfTask69 */70 protected function execute($arguments = array(), $options = array())71 {72 $env = $arguments['server'];73 $ini = sfConfig::get('sf_config_dir').'/properties.ini';74 if (!file_exists($ini))75 {76 throw new sfCommandException('You must create a config/properties.ini file');77 }78 $properties = parse_ini_file($ini, true);79 if (!isset($properties[$env]))80 {81 throw new sfCommandException(sprintf('You must define the configuration for server "%s" in config/properties.ini', $env));82 }83 $properties = $properties[$env];84 if (!isset($properties['host']))85 {86 throw new sfCommandException('You must define a "host" entry.');87 }88 if (!isset($properties['dir']))89 {90 throw new sfCommandException('You must define a "dir" entry.');91 }92 $host = $properties['host'];93 $dir = $properties['dir'];94 $user = isset($properties['user']) ? $properties['user'].'@' : '';95 if (substr($dir, -1) != '/')96 {97 $dir .= '/';98 }99 $ssh = 'ssh';100 if (isset($properties['port']))101 {102 $port = $properties['port'];103 $ssh = '"ssh -p'.$port.'"';104 }105 if (isset($properties['parameters']))106 {107 $parameters = $properties['parameters'];108 }109 else110 {111 $parameters = $options['rsync-options'];112 if (file_exists($options['rsync-dir'].'/rsync_exclude.txt'))113 {114 $parameters .= sprintf(' --exclude-from=%s/rsync_exclude.txt', $options['rsync-dir']);115 }116 if (file_exists($options['rsync-dir'].'/rsync_include.txt'))117 {118 $parameters .= sprintf(' --include-from=%s/rsync_include.txt', $options['rsync-dir']);119 }120 if (file_exists($options['rsync-dir'].'/rsync.txt'))121 {...
properties
Using AI Code Generation
1$must = new Must();2$must->setProp1(10);3$must->setProp2(20);4$must->setProp3(30);5$must->setProp4(40);6$must->setProp5(50);7$must->setProp6(60);8$must->setProp7(70);9$must->setProp8(80);10$must->setProp9(90);11$must->setProp10(100);12$must->setProp11(110);13$must->setProp12(120);14$must->setProp13(130);15$must->setProp14(140);16$must->setProp15(150);17$must->setProp16(160);18$must->setProp17(170);19$must->setProp18(180);20$must->setProp19(190);21$must->setProp20(200);22$must->setProp21(210);23$must->setProp22(220);24$must->setProp23(230);25$must->setProp24(240);26$must->setProp25(250);27$must->setProp26(260);28$must->setProp27(270);29$must->setProp28(280);30$must->setProp29(290);31$must->setProp30(300);32$must->setProp31(310);33$must->setProp32(320);34$must->setProp33(330);35$must->setProp34(340);36$must->setProp35(350);37$must->setProp36(360);38$must->setProp37(370);39$must->setProp38(380);40$must->setProp39(390);41$must->setProp40(400);42$must->setProp41(410);43$must->setProp42(420);44$must->setProp43(430);45$must->setProp44(440);46$must->setProp45(450);47$must->setProp46(460);48$must->setProp47(470);49$must->setProp48(480);50$must->setProp49(490);51$must->setProp50(500);52$must->setProp51(510);53$must->setProp52(520);54$must->setProp53(530);55$must->setProp54(540);
properties
Using AI Code Generation
1$must->properties = array(2 'name' => array(3 'age' => array(4 'email' => array(5 'url' => array(6 'date' => array(7 'time' => array(8 'datetime' => array(9 'ip' => array(10 'ipv4' => array(11 'ipv6' => array(12 'hostname' => array(13 'creditcard' => array(14 'alphanumeric' => array(15 'alpha' => array(
properties
Using AI Code Generation
1$must = new Must();2$must->name = 'Must';3$must->age = 25;4echo $must->name . ' is ' . $must->age . ' years old.';5$must = new Must();6$must->name = 'Must';7$must->age = 25;8echo $must->name . ' is ' . $must->age . ' years old.';9$must = new Must();10$must->name = 'Must';11$must->age = 25;12echo $must->name . ' is ' . $must->age . ' years old.';13$must = new Must();14$must->name = 'Must';15$must->age = 25;16echo $must->name . ' is ' . $must->age . ' years old.';17$must = new Must();18$must->name = 'Must';19$must->age = 25;20echo $must->name . ' is ' . $must->age . ' years old.';21$must = new Must();22$must->name = 'Must';23$must->age = 25;24echo $must->name . ' is ' . $must->age . ' years old.';25$must = new Must();26$must->name = 'Must';27$must->age = 25;28echo $must->name . ' is ' . $must->age . ' years old.';
properties
Using AI Code Generation
1require_once 'must.php';2$must = new Must();3$must->name = 'Must';4$must->age = 30;5require_once 'must.php';6$must = new Must();7$must->name = 'Must';8$must->age = 30;9require_once 'must.php';10$must = new Must();11$must->name = 'Must';12$must->age = 30;13require_once 'must.php';14$must = new Must();15$must->name = 'Must';16$must->age = 30;17require_once 'must.php';18$must = new Must();19$must->name = 'Must';20$must->age = 30;21require_once 'must.php';22$must = new Must();23$must->name = 'Must';24$must->age = 30;25require_once 'must.php';26$must = new Must();27$must->name = 'Must';28$must->age = 30;29require_once 'must.php';30$must = new Must();31$must->name = 'Must';32$must->age = 30;
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with properties on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!