/** * @group view */ public function testChangeViewWithCheckOption() { $select = 'select usr_id from users'; $options = array('check' => 'wrong'); try { $this->object->changeView('v_users', $select, $options); $this->fail('the check option of changeView is wrong'); } catch (Phigrate_Exception_Argument $e) { $msg = 'check option allowed for change view : LOCAL, CASCADED'; $this->assertEquals($msg, $e->getMessage()); } $this->object->setExport('true'); $expected = 'ALTER ALGORITHM=UNDEFINED DEFINER=CURRENT_USER VIEW `v_users` AS select usr_id from users WITH CASCADED CHECK OPTION;'; $options = array('check' => true); $this->object->changeView('v_users', $select, $options); $actual = $this->object->getSql(); $this->assertStringStartsWith($expected, $actual); $this->object->setExport('true'); $expected = 'ALTER ALGORITHM=UNDEFINED DEFINER=CURRENT_USER VIEW `v_users` AS select usr_id from users WITH LOCAL CHECK OPTION;'; $options = array('check' => 'LOCAL'); $this->object->changeView('v_users', $select, $options); $actual = $this->object->getSql(); $this->assertStringStartsWith($expected, $actual); }