/**
  * @return void
  */
 public function testRecursive()
 {
     $result = $this->Addresses->find()->contain([$this->Users->alias(), $this->Comments->alias()])->first();
     $hashid = 'jR';
     $this->assertSame($hashid, $result->id);
     $this->assertSame(1, $result->comments[0]->id);
     $this->assertSame(1, $result->user->id);
     $this->Addresses->behaviors()->Hashid->config('recursive', true);
     $result = $this->Addresses->find()->contain([$this->Users->alias(), $this->Comments->alias()])->first();
     $hashid = 'jR';
     $this->assertSame($hashid, $result->id);
     $this->assertSame($hashid, $result->comments[0]->id);
     $this->assertSame($hashid, $result->user->id);
 }
 /**
  * GeocoderBehaviorTest::testExpect()
  *
  * @return void
  */
 public function testExpect()
 {
     $this->Addresses->removeBehavior('Geocoder');
     $this->Addresses->addBehavior('Geo.Geocoder', ['real' => false, 'expect' => ['postal_code']]);
     $data = ['city' => 'Bibersfeld, Deutschland'];
     $entity = $this->_getEntity($data);
     $res = $this->Addresses->save($entity);
     $this->assertTrue(empty($res['lat']) && empty($res['lng']));
     $data = ['city' => '74523, Deutschland'];
     $entity = $this->_getEntity($data);
     $res = $this->Addresses->save($entity);
     $this->assertEquals('74523 Schwäbisch Hall, Deutschland', $res['formatted_address']);
     $this->assertTrue(!empty($res['lat']) && !empty($res['lng']));
 }
 /**
  * GeocoderBehaviorTest::testExpect()
  *
  * @return void
  */
 public function testExpect()
 {
     $this->Addresses->removeBehavior('Geocoder');
     $this->Addresses->addBehavior('Geocoder', ['real' => false, 'expect' => [Geocoder::TYPE_POSTAL]]);
     $data = ['city' => 'Berlin, Deutschland'];
     $entity = $this->_getEntity($data);
     $res = $this->Addresses->save($entity);
     $this->assertTrue(empty($res['lat']) && empty($res['lng']));
     $data = ['city' => '74523, Deutschland'];
     $entity = $this->_getEntity($data);
     $res = $this->Addresses->save($entity);
     $this->assertContains('74523 Schwäbisch Hall', $res['formatted_address']);
     //$this->assertEquals('74523 Schwäbisch Hall, Deutschland', $res['formatted_address']);
     $this->assertTrue(!empty($res['lat']) && !empty($res['lng']));
 }
 /**
  * @return void
  */
 public function testSave()
 {
     $captcha = $this->Captchas->newEntity(['result' => 3, 'ip' => '127.0.0.1', 'session_id' => 1, 'created' => new DateTime('- 1 hour'), 'modified' => new DateTime('- 1 hour')]);
     $result = $this->Captchas->save($captcha);
     $this->assertTrue((bool) $result);
     $id = $captcha->id;
     $data = ['comment' => 'Foo'];
     $comment = $this->Comments->newEntity($data);
     $res = $this->Comments->save($comment);
     $this->assertFalse((bool) $res);
     $data['captcha_id'] = $id;
     $data['captcha_result'] = 2;
     $data['email_homepage'] = '';
     $comment = $this->Comments->newEntity($data);
     $res = $this->Comments->save($comment);
     $this->assertFalse((bool) $res);
     $data['captcha_result'] = 3;
     $data['email_homepage'] = '';
     $comment = $this->Comments->newEntity($data);
     $res = $this->Comments->save($comment);
     $this->assertTrue((bool) $res);
     $captcha = $this->Captchas->get($id);
     $this->assertNotEmpty($captcha->used);
 }
示例#5
0
 /**
  * Set the validation rule set to use.
  *
  * @param string $validate Name of the validation rule set to use.
  * @return \Cake\ORM\SaveOptionsBuilder
  */
 public function validate($validate)
 {
     $this->_table->validator($validate);
     $this->_options['validate'] = $validate;
     return $this;
 }