private function assert_dirtifies($method) { $model = new Author(); $datetime = new DateTime(); $datetime->attribute_of($model, 'some_date'); $args = func_get_args(); array_shift($args); call_user_func_array(array($datetime, $method), $args); $this->assert_has_keys('some_date', $model->dirty_attributes()); }
private function assert_dirtifies($method) { try { $model = new Author(); } catch (DatabaseException $e) { $this->mark_test_skipped('failed to connect. ' . $e->getMessage()); } $datetime = new DateTime(); $datetime->attribute_of($model, 'some_date'); $args = func_get_args(); array_shift($args); call_user_func_array(array($datetime, $method), $args); $this->assert_has_keys('some_date', $model->dirty_attributes()); }
public function test_clone() { $model = $this->get_model(); $model_attribute = 'some_date'; $datetime = new DateTime(); $datetime->attribute_of($model, $model_attribute); $cloned_datetime = clone $datetime; // Assert initial state $this->assert_false($model->attribute_is_dirty($model_attribute)); $cloned_datetime->add(new DateInterval('PT1S')); // Assert that modifying the cloned object didn't flag the model $this->assert_false($model->attribute_is_dirty($model_attribute)); $datetime->add(new DateInterval('PT1S')); // Assert that modifying the model-attached object did flag the model $this->assert_true($model->attribute_is_dirty($model_attribute)); // Assert that the dates are equal but not the same instance $this->assert_equals($datetime, $cloned_datetime); $this->assert_not_same($datetime, $cloned_datetime); }