コード例 #1
0
 public function testSave()
 {
     //  test save subscriber
     $subscriber = new Subscriber();
     $subscriber->user_id = 1;
     $this->assertEquals(true, $subscriber->save(), 'Can not save subscriber');
     $channel = new Channel();
     $channel->name = 'test';
     $this->assertEquals(true, $channel->save(), 'Can not save channel');
 }
コード例 #2
0
 public function createChannel()
 {
     $this->_channel = new Channel();
     $this->attributesToChannel($this->_channel);
     $this->_channel->name = $this->getChannelName();
     $event = new ArEvent($this);
     $event->name = 'onChannelSave';
     $event->error = !$this->_channel->save();
     $this->triggerModelEvent($event);
 }
コード例 #3
0
 public function testDelete()
 {
     $channel = new Channel();
     $channel->attributes = array('name' => 'test6' . time(), 'subscriber_source' => Channel::SOURCE_PHP, 'event_source' => Channel::SOURCE_PHP);
     $this->assertEquals(true, $channel->getIsNewRecord());
     $this->assertEquals(true, $channel->save());
     //  try find channel
     $channel = Channel::model()->findByPk($channel->id);
     $this->assertInstanceOf('YiiNodeSocket\\Models\\Channel', $channel);
     //  try delete
     $this->assertEquals(true, $channel->delete());
     //  try find again
     $channel = Channel::model()->findByPk($channel->id);
     //  should be null
     $this->assertNull($channel);
 }