/** * @return void */ public function setUp() { parent::setUp(); Configure::write('Captcha', ['debug' => false]); $this->request = new Request(); $this->request->env('REMOTE_ADDR', '127.0.0.1'); $this->session = $this->getMockBuilder(Session::class)->setMethods(['id'])->getMock(); $this->session->expects($this->once())->method('id')->willReturn(1); $this->request->session($this->session); Router::pushRequest($this->request); Router::reload(); $this->Captchas = TableRegistry::get('Captcha.Captchas'); $this->Comments = TableRegistry::get('Captcha.Comments'); $this->Comments->addBehavior('Captcha.Captcha'); }
/** * @return void */ public function testFindDebugMode() { Configure::write('debug', true); $this->Addresses->removeBehavior('Hashid'); $this->Addresses->addBehavior('Hashid.Hashid', ['field' => 'hashid', 'debug' => null]); $data = ['city' => 'Foo']; $address = $this->Addresses->newEntity($data); $res = $this->Addresses->save($address); $id = $address->id; $hasher = new Hashids(); $hashid = $hasher->encode($id) . '-' . $id; $address = $this->Addresses->find('hashed', [HashidBehavior::HID => $hashid])->first(); $this->assertTrue((bool) $address); }
/** * 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'])); }