svn: /pear2/BugManager/trunk/ src/BugManager/IssueDecorator/Mysql.php tests/MysqlIssueDecorator/insertsql.phpt

From: Date: Wed, 12 Aug 2009 18:36:30 +0000
Subject: svn: /pear2/BugManager/trunk/ src/BugManager/IssueDecorator/Mysql.php tests/MysqlIssueDecorator/insertsql.phpt
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-cvs+get-57074@lists.php.net to get a copy of this message
cellog Wed, 12 Aug 2009 18:36:30 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=287171 Log: new test for insert sql Changed paths: U pear2/BugManager/trunk/src/BugManager/IssueDecorator/Mysql.php A pear2/BugManager/trunk/tests/MysqlIssueDecorator/insertsql.phpt Modified: pear2/BugManager/trunk/src/BugManager/IssueDecorator/Mysql.php =================================================================== --- pear2/BugManager/trunk/src/BugManager/IssueDecorator/Mysql.php 2009-08-12 18:25:02 UTC (rev 287170) +++ pear2/BugManager/trunk/src/BugManager/IssueDecorator/Mysql.php 2009-08-12 18:36:30 UTC (rev 287171) @@ -85,7 +85,7 @@ (bug_id, email, handle, reporter_name, ts, comment) VALUES(" . $id . ', "' . $this->manager->esc($comment->commenter->email) . '", - "' . $this->manager->esc($comment->commenter->handle) . '", + "' . $this->manager->esc($comment->commenter->uniqueId()) . '", "' . $this->manager->esc($comment->commenter->name) . '", "' . $this->manager->esc($comment->timestamp->format('Y-m-d H:i:s')) . '", "' . $this->manager->esc($comment->comment) . '");'] = $comment; Added: pear2/BugManager/trunk/tests/MysqlIssueDecorator/insertsql.phpt =================================================================== --- pear2/BugManager/trunk/tests/MysqlIssueDecorator/insertsql.phpt (rev 0) +++ pear2/BugManager/trunk/tests/MysqlIssueDecorator/insertsql.phpt 2009-08-12 18:36:30 UTC (rev 287171) @@ -0,0 +1,57 @@ +--TEST-- +BugManager\IssueDecorator\Mysql: test update sql +--FILE-- +<?php +require __DIR__ . '/setup.php.inc'; +require __DIR__ . '/../fake_mysqli.php.inc'; +pear2\BugManager\Main::setSite('pear'); +pear2\BugManager\IssueManager\Mysql::$mysqliclass = 'fake_mysqli'; +pear2\BugManager\IssueManager\Mysql::$defaultActorManager = new pear2\BugManager\ActorManager\PearMysql('localhost'); +$mysql = new fake_mysqli; +$mysql->makePackagesTable(); +$mysql->makeReleasesTable(); +$mysql->makeUsersTable(); +$mysql->makePackage('Foo'); +$mysql->releasePackage('Foo', '1.2.3'); +$mysql->addUser(md5('foo@example.com'), 'Bill', 'foo@example.com'); +$mysql->addUser('cellog', 'Greg Beaver', 'cellog@php.net'); +$mysql->grant('cellog', 'pear.admin'); +$mysql->addUser('saltybeagle', 'Brett Bieber', 'saltybeagle@php.net'); +$mysql->grant('saltybeagle', 'pear.dev'); + +$mysql = new pear2\BugManager\IssueManager\Mysql('localhost', 'doh'); +$newbug = new pear2\BugManager\Issue($mysql); +$newbug->status = 'Open'; +$newbug->type = 'Bug'; +$newbug->createtimestamp = '2008-10-15 21:35:00'; +$newbug->modifiedtimestamp = "2009-07-26 23:35:00"; +$newbug->summary = 'Short description'; +$newbug->reporter = pear2\BugManager\Actor::findByEmail('foo@example.com'); +$newbug->context['phpversion'] = '5.3.1'; +$newbug->context['operatingsystem'] = null; +$newbug->context['packagename'] = 'Foo'; +$newbug->context['packageversion'] = '1.2.3'; +$newbug->newComment("Long +Long Description", pear2\BugManager\Actor::findByEmail('foo@example.com'), '2008-10-15 21:35:00'); +$newbug->newComment('Comment 1', pear2\BugManager\Actor::findByHandle('cellog'), "2009-08-09 23:55:00"); +$newbug->assigned = array(pear2\BugManager\Actor::findByHandle('saltybeagle'),pear2\BugManager\Actor::findByHandle('cellog')); + +$deco = new pear2\BugManager\IssueDecorator\Mysql($newbug); +$test->assertEquals('INSERT INTO bugmanager_issues (package_name,bug_type,handle,email,reporter_name,sdesc,ldesc,package_version,php_version,status,ts1,ts2,assign,registered) + VALUES("Foo","Bug","b48def645758b95537d4424c84d1a9ff","foo@example.com","Bill","Short description","Long +Long Description","1.2.3","5.3.1","Open","2008-10-15 21:35:00","2009-07-26 23:35:00","saltybeagle|cellog","1");', (string) $deco, 'basic insert'); +$sql = $deco->getCommentInsertSql(1); +$test->assertEquals(array(' +INSERT INTO bugmanager_comments + (bug_id, email, handle, reporter_name, ts, comment) + VALUES(1, + "cellog@php.net", + "cellog", + "Greg Beaver", + "2009-08-09 23:55:00", + "Comment 1");'), array_keys($sql), 'sql'); +$test->assertSame(array($newbug->comments[1]), array_values($sql), 'comment'); +?> +===DONE=== +--EXPECT-- +===DONE=== \ No newline at end of file

« previous php.pear.cvs (#57074) next »