Skip to content
Browse files

Enable File_MARC_Record to be invoked with a null constructor

git-svn-id: https://svn.php.net/repository/pear/packages/File_MARC/trunk@301892 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent ddb67ce commit 302d4afa9a69b1372205a2ba7cd80edaae4357d1 Dan Scott committed Aug 5, 2010
Showing with 33 additions and 5 deletions.
  1. +4 −1 MARC/Record.php
  2. +6 −4 package.xml
  3. +23 −0 tests/marc_record_001.phpt
View
5 MARC/Record.php
@@ -101,10 +101,13 @@ class File_MARC_Record
*
* @return true
*/
- function __construct($marc)
+ function __construct($marc = null)
{
$this->fields = new File_MARC_List();
$this->leader = str_repeat(' ', 24);
+ if (!$marc) {
+ $marc = new File_MARC(null, File_MARC::SOURCE_STRING); // oh the hack
+ }
$this->marc = $marc;
$this->marcxml = $marc->getXMLWriter();
}
View
10 package.xml
@@ -19,9 +19,9 @@ This package is based on the PHP MARC package, originally called "php-marc", tha
<email>dbs@php.net</email>
<active>yes</active>
</lead>
- <date>2010-07-31</date>
+ <date>2010-08-05</date>
<version>
- <release>0.5.1</release>
+ <release>0.5.2</release>
<api>0.5.0</api>
</version>
<stability>
@@ -30,8 +30,9 @@ This package is based on the PHP MARC package, originally called "php-marc", tha
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">GNU Lesser General Public License</license>
<notes>
-0.5.1-beta
- * Explicitly cast results to strings to avoid returning XML objects when File_MARCXML is in effect; problem doesn't show up in the PHP CLI, but does cause problems on the Web
+0.5.2-beta
+ * Enable File_MARC_Record to be invoked with a null constructor again, useful for building MARC records from scratch
+ * Add a test to check that the null constructor works to avoid future regressions
</notes>
<contents>
<dir name="/" baseinstalldir="File">
@@ -80,6 +81,7 @@ This package is based on the PHP MARC package, originally called "php-marc", tha
<file name="marc_field_002.phpt" role="test" />
<file name="marc_field_003.phpt" role="test" />
<file name="marc_field_004.phpt" role="test" />
+ <file name="marc_record_001.phpt" role="test" />
<file name="marc_subfield_001.phpt" role="test" />
<file name="marc_subfield_002.phpt" role="test" />
<file name="marc_xml_001.phpt" role="test" />
View
23 tests/marc_record_001.phpt
@@ -0,0 +1,23 @@
+--TEST--
+marc_record_001: create a MARC record from scratch
+--FILE--
+<?php
+$dir = dirname(__FILE__);
+require 'File/MARC.php';
+$marc = new File_MARC_Record();
+
+$marc->appendField(new File_MARC_Data_Field('245', array(
+ new File_MARC_Subfield('a', 'Main title: '),
+ new File_MARC_Subfield('b', 'subtitle'),
+ new File_MARC_Subfield('c', 'author')
+ ), null, null
+));
+
+print $marc;
+
+?>
+--EXPECT--
+LDR
+245 _aMain title:
+ _bsubtitle
+ _cauthor

0 comments on commit 302d4af

Please sign in to comment.
Something went wrong with that request. Please try again.